[][src]Struct hyper::server::Server

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]

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]

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]

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]

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

impl<S, B> !UnwindSafe for Server<S, B>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.