Struct hyper::server::Server
[−]
[src]
pub struct Server<S, B> where
B: Stream<Error = Error>,
B::Item: AsRef<[u8]>, { /* fields omitted */ }
An instance of a server created through Http::bind
.
This server is intended as a convenience for creating a TCP listener on an address and then serving TCP connections accepted with the service provided.
Methods
impl<S, B> Server<S, B> where
S: NewService<Request = Request, Response = Response<B>, Error = Error> + 'static,
B: Stream<Error = Error> + 'static,
B::Item: AsRef<[u8]>,
[src]
S: NewService<Request = Request, Response = Response<B>, Error = Error> + 'static,
B: Stream<Error = Error> + 'static,
B::Item: AsRef<[u8]>,
pub fn local_addr(&self) -> Result<SocketAddr>
[src]
Returns the local address that this server is bound to.
pub fn handle(&self) -> Handle
[src]
Returns a handle to the underlying event loop that this server will be running on.
ⓘImportant traits for &'a mut Rpub fn shutdown_timeout(&mut self, timeout: Duration) -> &mut Self
[src]
Configure the amount of time this server will wait for a "graceful shutdown".
This is the amount of time after the shutdown signal is received the server will wait for all pending connections to finish. If the timeout elapses then the server will be forcibly shut down.
This defaults to 1s.
pub fn run(self) -> Result<()>
[src]
Execute this server infinitely.
This method does not currently return, but it will return an error if one occurs.
pub fn run_until<F>(self, shutdown_signal: F) -> Result<()> where
F: Future<Item = (), Error = ()>,
[src]
F: Future<Item = (), Error = ()>,
Execute this server until the given future, shutdown_signal
, resolves.
This method, like run
above, is used to execute this HTTP server. The
difference with run
, however, is that this method allows for shutdown
in a graceful fashion. The future provided is interpreted as a signal to
shut down the server when it resolves.
This method will block the current thread executing the HTTP server.
When the shutdown_signal
has resolved then the TCP listener will be
unbound (dropped). The thread will continue to block for a maximum of
shutdown_timeout
time waiting for active connections to shut down.
Once the shutdown_timeout
elapses or all active connections are
cleaned out then this method will return.
impl<S, B> Server<S, B> where
S: NewService<Request = Request, Response = Response<B>, Error = Error> + Send + Sync + 'static,
B: Stream<Error = Error> + 'static,
B::Item: AsRef<[u8]>,
[src]
S: NewService<Request = Request, Response = Response<B>, Error = Error> + Send + Sync + 'static,
B: Stream<Error = Error> + 'static,
B::Item: AsRef<[u8]>,
pub fn run_threads(self, threads: usize)
[src]
Run the server on multiple threads.
Trait Implementations
impl<S: Debug, B: Stream<Error = Error>> Debug for Server<S, B> where
B::Item: AsRef<[u8]>,
[src]
B::Item: AsRef<[u8]>,