[−][src]Struct hyper::server::Server
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.
pub 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
Auto Trait Implementations
impl<S, B> !RefUnwindSafe for Server<S, B>
impl<S, B> !Send for Server<S, B>
impl<S, B> !Sync for Server<S, B>
impl<S, B> Unpin for Server<S, B> where
S: Unpin,
S: Unpin,
impl<S, B> !UnwindSafe for Server<S, B>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,