#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))] pubtrait NewSvcExec<I, N, S: HttpService<Body>, E, W: Watcher<I, S, E>>: Clone { fn execute_new_svc(&mutself, fut: NewSvcTask<I, N, S, E, W>);
}
pub(crate) type BoxSendFuture = Pin<Box<dyn Future<Output = ()> + Send>>;
// Either the user provides an executor for background tasks, or we use // `tokio::spawn`. #[derive(Clone)] pubenum Exec {
Default,
Executor(Arc<dyn Executor<BoxSendFuture> + Send + Sync>),
}
// ===== impl Exec =====
impl Exec { pub(crate) fn execute<F>(&self, fut: F) where
F: Future<Output = ()> + Send + 'static,
{ match *self {
Exec::Default => { #[cfg(feature = "tcp")]
{
tokio::task::spawn(fut);
} #[cfg(not(feature = "tcp"))]
{ // If no runtime, we need an executor!
panic!("executor must be set")
}
}
Exec::Executor(ref e) => {
e.execute(Box::pin(fut));
}
}
}
}
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))] impl<I, N, S, E, W> NewSvcExec<I, N, S, E, W> for E where
E: Executor<NewSvcTask<I, N, S, E, W>> + Clone,
NewSvcTask<I, N, S, E, W>: Future<Output = ()>,
S: HttpService<Body>,
W: Watcher<I, S, E>,
{ fn execute_new_svc(&mutself, fut: NewSvcTask<I, N, S, E, W>) { self.execute(fut)
}
}
// If http2 is not enable, we just have a stub here, so that the trait bounds // that *would* have been needed are still checked. Why? // // Because enabling `http2` shouldn't suddenly add new trait bounds that cause // a compilation error. #[cfg(not(feature = "http2"))] #[allow(missing_debug_implementations)] pubstruct H2Stream<F, B>(std::marker::PhantomData<(F, B)>);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.