pub struct Server { /* private fields */ }Implementations§
Source§impl Server
impl Server
Sourcepub fn builder(registry: Registry) -> ServerBuilder
pub fn builder(registry: Registry) -> ServerBuilder
Begin a builder chain for an HTTP server backed by registry.
Sourcepub fn local_addr(&self) -> Option<SocketAddr>
pub fn local_addr(&self) -> Option<SocketAddr>
Address the server is bound to. None until the listener has
successfully bound (i.e. after serve has set it). Tests use
this to discover the kernel-chosen port when listen was
127.0.0.1:0.
Sourcepub fn shutdown(&mut self) -> bool
pub fn shutdown(&mut self) -> bool
Trigger a graceful shutdown. Returns false if the server was
never started or has already been signalled.
Sourcepub async fn serve(self, router: Router) -> Result<(), HttpServerError>
pub async fn serve(self, router: Router) -> Result<(), HttpServerError>
Bind + serve. Returns when the listener stops accepting (typically
triggered by Server::shutdown or a fatal accept error).
Sourcepub async fn bind(&mut self) -> Result<TcpListener, HttpServerError>
pub async fn bind(&mut self) -> Result<TcpListener, HttpServerError>
Bind only — returns the bound TcpListener + the resolved local
address. Tests use this to learn the kernel-chosen port before
driving serve on a separate task.
Sourcepub async fn serve_with_listener(
self,
listener: TcpListener,
router: Router,
) -> Result<(), HttpServerError>
pub async fn serve_with_listener( self, listener: TcpListener, router: Router, ) -> Result<(), HttpServerError>
Serve on a pre-bound listener (paired with bind). Useful for
tests that need the local address before the serve future starts.