This commit is contained in:
nora 2023-03-07 16:36:38 +01:00
parent 3646dc4c88
commit b40c185fc9
2 changed files with 13 additions and 16 deletions

View file

@ -18,8 +18,8 @@ pub trait ConnStreamExec<F, B: HttpBody>: Clone {
fn execute_h2stream(&mut self, fut: H2Stream<F, B>); fn execute_h2stream(&mut self, fut: H2Stream<F, B>);
} }
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))] #[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
pub trait NewSvcExec<I, N, S, E, W: Watcher<I, S, E>>: Clone { pub trait NewSvcExec<I, S, E, W: Watcher<I, S, E>>: Clone {
fn execute_new_svc(&mut self, fut: NewSvcTask<I, N, S, E, W>); fn execute_new_svc(&mut self, fut: NewSvcTask<I, S, E, W>);
} }
pub(crate) type BoxSendFuture = Pin<Box<dyn Future<Output = ()> + Send>>; pub(crate) type BoxSendFuture = Pin<Box<dyn Future<Output = ()> + Send>>;
#[derive(Clone)] #[derive(Clone)]
@ -43,13 +43,13 @@ where
} }
} }
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))] #[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
impl<I, N, S, E, W> NewSvcExec<I, N, S, E, W> for Exec impl<I, S, E, W> NewSvcExec<I, S, E, W> for Exec
where where
NewSvcTask<I, N, S, E, W>: Future<Output = ()> + Send + 'static, NewSvcTask<I, S, E, W>: Future<Output = ()> + Send + 'static,
S: HttpService<Body>, S: HttpService<Body>,
W: Watcher<I, S, E>, W: Watcher<I, S, E>,
{ {
fn execute_new_svc(&mut self, fut: NewSvcTask<I, N, S, E, W>) { fn execute_new_svc(&mut self, fut: NewSvcTask<I, S, E, W>) {
loop {} loop {}
} }
} }
@ -65,14 +65,14 @@ where
} }
} }
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))] #[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
impl<I, N, S, E, W> NewSvcExec<I, N, S, E, W> for E impl<I, S, E, W> NewSvcExec<I, S, E, W> for E
where where
E: Executor<NewSvcTask<I, N, S, E, W>> + Clone, E: Executor<NewSvcTask<I, S, E, W>> + Clone,
NewSvcTask<I, N, S, E, W>: Future<Output = ()>, NewSvcTask<I, S, E, W>: Future<Output = ()>,
S: HttpService<Body>, S: HttpService<Body>,
W: Watcher<I, S, E>, W: Watcher<I, S, E>,
{ {
fn execute_new_svc(&mut self, fut: NewSvcTask<I, N, S, E, W>) { fn execute_new_svc(&mut self, fut: NewSvcTask<I, S, E, W>) {
loop {} loop {}
} }
} }

View file

@ -46,7 +46,7 @@ where
I: Accept<Conn = IO, Error = IE>, I: Accept<Conn = IO, Error = IE>,
IE: Into<Box<dyn StdError + Send + Sync>>, IE: Into<Box<dyn StdError + Send + Sync>>,
S: MakeServiceRef<IO, Body>, S: MakeServiceRef<IO, Body>,
E: NewSvcExec<IO, S::Future, S::Service, E, NoopWatcher>, E: NewSvcExec<IO, S::Service, E, NoopWatcher>,
{ {
type Output = (); type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
@ -102,9 +102,8 @@ pub(crate) mod new_svc {
use std::error::Error as StdError; use std::error::Error as StdError;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
pub struct NewSvcTask<I, N, S, E, W: Watcher<I, S, E>> { pub struct NewSvcTask<I, S, E, W: Watcher<I, S, E>> {
state: State<I, S, E, W>, state: State<I, S, E, W>,
a: N,
} }
pub(super) enum State<I, S, E, W: Watcher<I, S, E>> { pub(super) enum State<I, S, E, W: Watcher<I, S, E>> {
@ -113,16 +112,14 @@ pub(crate) mod new_svc {
Connected { future: W::Future }, Connected { future: W::Future },
} }
impl<I, N, S: HttpService<Body>, E, W: Watcher<I, S, E>> NewSvcTask<I, N, S, E, W> { impl<I, S: HttpService<Body>, E, W: Watcher<I, S, E>> NewSvcTask<I, S, E, W> {
pub(super) fn new(watcher: W) -> Self { pub(super) fn new(watcher: W) -> Self {
loop {} loop {}
} }
} }
impl<I, N, S, NE, B, E, W> Future for NewSvcTask<I, N, S, E, W> impl<I, S, B, E, W> Future for NewSvcTask<I, S, E, W>
where where
I: AsyncRead + AsyncWrite + Unpin + Send + 'static, I: AsyncRead + AsyncWrite + Unpin + Send + 'static,
N: Future<Output = Result<S, NE>>,
NE: Into<Box<dyn StdError + Send + Sync>>,
S: HttpService<Body, ResBody = B>, S: HttpService<Body, ResBody = B>,
B: HttpBody + 'static, B: HttpBody + 'static,
B::Error: Into<Box<dyn StdError + Send + Sync>>, B::Error: Into<Box<dyn StdError + Send + Sync>>,