feat(service): rename Service to HttpService, re-export tower::Service`
The only important trait for a user is the `tower::Service` trait, which is now available also at `hyper::service::Service`. The other "trait aliases" are no longer publicly exported, as people thought they had to implement them. Also removes dependency on `tower-make`, which is trivial but otherwise shouldn't affect anyone. Closes #1959
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::body::{Body, Payload};
|
||||
use crate::common::{Future, Never, Poll, Pin, Unpin, task};
|
||||
use crate::proto::{BodyLength, DecodedLength, Conn, Dispatched, MessageHead, RequestHead, RequestLine, ResponseHead};
|
||||
use super::Http1Transaction;
|
||||
use crate::service::Service;
|
||||
use crate::service::HttpService;
|
||||
|
||||
pub(crate) struct Dispatcher<D, Bs: Payload, I, T> {
|
||||
conn: Conn<I, Bs::Data, T>,
|
||||
@@ -29,7 +29,7 @@ pub(crate) trait Dispatch {
|
||||
fn should_poll(&self) -> bool;
|
||||
}
|
||||
|
||||
pub struct Server<S: Service<B>, B> {
|
||||
pub struct Server<S: HttpService<B>, B> {
|
||||
in_flight: Pin<Box<Option<S::Future>>>,
|
||||
pub(crate) service: S,
|
||||
}
|
||||
@@ -407,7 +407,7 @@ impl<'a, T> Drop for OptGuard<'a, T> {
|
||||
|
||||
impl<S, B> Server<S, B>
|
||||
where
|
||||
S: Service<B>,
|
||||
S: HttpService<B>,
|
||||
{
|
||||
pub fn new(service: S) -> Server<S, B> {
|
||||
Server {
|
||||
@@ -422,11 +422,11 @@ where
|
||||
}
|
||||
|
||||
// Service is never pinned
|
||||
impl<S: Service<B>, B> Unpin for Server<S, B> {}
|
||||
impl<S: HttpService<B>, B> Unpin for Server<S, B> {}
|
||||
|
||||
impl<S, Bs> Dispatch for Server<S, Body>
|
||||
where
|
||||
S: Service<Body, ResBody=Bs>,
|
||||
S: HttpService<Body, ResBody=Bs>,
|
||||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||||
Bs: Payload,
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::common::exec::H2Exec;
|
||||
use crate::common::{Future, Pin, Poll, task};
|
||||
use crate::headers;
|
||||
use crate::headers::content_length_parse_all;
|
||||
use crate::service::Service;
|
||||
use crate::service::HttpService;
|
||||
use crate::proto::Dispatched;
|
||||
use super::{PipeToSendStream, SendBuf};
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::{Body, Response};
|
||||
|
||||
pub(crate) struct Server<T, S, B, E>
|
||||
where
|
||||
S: Service<Body>,
|
||||
S: HttpService<Body>,
|
||||
B: Payload,
|
||||
{
|
||||
exec: E,
|
||||
@@ -28,7 +28,7 @@ where
|
||||
}
|
||||
|
||||
// TODO: fix me
|
||||
impl<T, S: Service<Body>, B: Payload, E> Unpin for Server<T, S, B, E> {}
|
||||
impl<T, S: HttpService<Body>, B: Payload, E> Unpin for Server<T, S, B, E> {}
|
||||
|
||||
enum State<T, B>
|
||||
where
|
||||
@@ -51,7 +51,7 @@ where
|
||||
impl<T, S, B, E> Server<T, S, B, E>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
S: Service<Body, ResBody=B>,
|
||||
S: HttpService<Body, ResBody=B>,
|
||||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||||
B: Payload,
|
||||
B::Data: Unpin,
|
||||
@@ -89,7 +89,7 @@ where
|
||||
impl<T, S, B, E> Future for Server<T, S, B, E>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
S: Service<Body, ResBody=B>,
|
||||
S: HttpService<Body, ResBody=B>,
|
||||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||||
B: Payload,
|
||||
B::Data: Unpin,
|
||||
@@ -131,7 +131,7 @@ where
|
||||
{
|
||||
fn poll_server<S, E>(&mut self, cx: &mut task::Context<'_>, service: &mut S, exec: &mut E) -> Poll<crate::Result<()>>
|
||||
where
|
||||
S: Service<
|
||||
S: HttpService<
|
||||
Body,
|
||||
ResBody=B,
|
||||
>,
|
||||
|
||||
Reference in New Issue
Block a user