pub struct Server { /* private fields */ }Expand description
A high-level server type.
For examples, see the module doc.
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(connection_builder: Builder<TokioExecutor>) -> Self
pub fn new(connection_builder: Builder<TokioExecutor>) -> Self
Creates a new Server with the provided Builder.
Sourcepub fn with_graceful_shutdown_duration(self, duration: Duration) -> Self
pub fn with_graceful_shutdown_duration(self, duration: Duration) -> Self
Sets the graceful shutdown duration. By default, the server shuts down immediately.
Sourcepub async fn serve<S, A>(
&self,
service: S,
listener_addresses: A,
) -> Result<(), ServerError>
pub async fn serve<S, A>( &self, service: S, listener_addresses: A, ) -> Result<(), ServerError>
Serves HTTP connections with the service on the first successfully
bound listener address.
§Panics
- if there is no valid address with an unused port to bind
TcpListener - on Unix systems if getting a signal listener to listen to
SIGTERM, has failed
Sourcepub async fn serve_with_tls<S, A>(
&self,
service: S,
listener_addresses: A,
tls_server_config: TlsServerConfig,
) -> Result<(), ServerError>
Available on crate feature tls only.
pub async fn serve_with_tls<S, A>( &self, service: S, listener_addresses: A, tls_server_config: TlsServerConfig, ) -> Result<(), ServerError>
tls only.Serves HTTPS connections with the service on the first successfully
bound listener address.
TLS can be configured with TlsServerConfig (TlsServerConfig is an alias
for rustls’s ServerConfig).
§Panics
- if there is no valid address with an unused port to bind
TcpListener - on Unix systems if getting a signal listener to listen to
SIGTERM, has failed
Auto Trait Implementations§
impl Freeze for Server
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
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