pub struct Serve<L, M, S> { /* private fields */ }
Available on crate feature
tokio
and (crate features http1
or http2
) only.Expand description
Future returned by serve
.
Implementations§
Source§impl<L, M, S> Serve<L, M, S>where
L: Listener,
impl<L, M, S> Serve<L, M, S>where
L: Listener,
Sourcepub fn with_graceful_shutdown<F>(
self,
signal: F,
) -> WithGracefulShutdown<L, M, S, F>
pub fn with_graceful_shutdown<F>( self, signal: F, ) -> WithGracefulShutdown<L, M, S, F>
Prepares a server to handle graceful shutdown when the provided future completes.
§Example
use axum::{Router, routing::get};
let router = Router::new().route("/", get(|| async { "Hello, World!" }));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, router)
.with_graceful_shutdown(shutdown_signal())
.await
.unwrap();
async fn shutdown_signal() {
// ...
}
Sourcepub fn local_addr(&self) -> Result<L::Addr>
pub fn local_addr(&self) -> Result<L::Addr>
Returns the local address this server is bound to.
Trait Implementations§
Source§impl<L, M, S> IntoFuture for Serve<L, M, S>where
L: Listener,
L::Addr: Debug,
M: for<'a> Service<IncomingStream<'a, L>, Error = Infallible, Response = S> + Send + 'static,
for<'a> <M as Service<IncomingStream<'a, L>>>::Future: Send,
S: Service<Request, Response = Response, Error = Infallible> + Clone + Send + 'static,
S::Future: Send,
impl<L, M, S> IntoFuture for Serve<L, M, S>where
L: Listener,
L::Addr: Debug,
M: for<'a> Service<IncomingStream<'a, L>, Error = Infallible, Response = S> + Send + 'static,
for<'a> <M as Service<IncomingStream<'a, L>>>::Future: Send,
S: Service<Request, Response = Response, Error = Infallible> + Clone + Send + 'static,
S::Future: Send,
Source§type IntoFuture = ServeFuture
type IntoFuture = ServeFuture
Which kind of future are we turning this into?
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Auto Trait Implementations§
impl<L, M, S> Freeze for Serve<L, M, S>
impl<L, M, S> RefUnwindSafe for Serve<L, M, S>
impl<L, M, S> Send for Serve<L, M, S>
impl<L, M, S> Sync for Serve<L, M, S>
impl<L, M, S> Unpin for Serve<L, M, S>
impl<L, M, S> UnwindSafe for Serve<L, M, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more