Struct warp::Server [−][src]
pub struct Server<S> { /* fields omitted */ }
A Warp Server ready to filter requests.
Methods
impl<S> Server<S> where
S: IntoWarpService + 'static,
<<S::Service as WarpService>::Reply as Future>::Item: Reply + Send,
<<S::Service as WarpService>::Reply as Future>::Error: Reject + Send,
[src]
impl<S> Server<S> where
S: IntoWarpService + 'static,
<<S::Service as WarpService>::Reply as Future>::Item: Reply + Send,
<<S::Service as WarpService>::Reply as Future>::Error: Reject + Send,
pub fn run(
self,
addr: impl Into<SocketAddr> + 'static
)
[src]
pub fn run(
self,
addr: impl Into<SocketAddr> + 'static
)
Run this Server
forever on the current thread.
pub fn run_incoming<I>(self, incoming: I) where
I: Stream + Send + 'static,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
I::Error: Into<Box<Error + Send + Sync>>,
[src]
pub fn run_incoming<I>(self, incoming: I) where
I: Stream + Send + 'static,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
I::Error: Into<Box<Error + Send + Sync>>,
Run this Server
forever on the current thread with a specific stream
of incoming connections.
This can be used for Unix Domain Sockets, or TLS, etc.
pub fn bind(
self,
addr: impl Into<SocketAddr> + 'static
) -> impl Future<Item = (), Error = ()> + 'static
[src]
pub fn bind(
self,
addr: impl Into<SocketAddr> + 'static
) -> impl Future<Item = (), Error = ()> + 'static
Bind to a socket address, returning a Future
that can be
executed on any runtime.
pub fn bind_ephemeral(
self,
addr: impl Into<SocketAddr> + 'static
) -> (SocketAddr, impl Future<Item = (), Error = ()> + 'static)
[src]
pub fn bind_ephemeral(
self,
addr: impl Into<SocketAddr> + 'static
) -> (SocketAddr, impl Future<Item = (), Error = ()> + 'static)
Bind to a possibly ephemeral socket address.
Returns the bound address and a Future
that can be executed on
any runtime.
pub fn bind_with_graceful_shutdown(
self,
addr: impl Into<SocketAddr> + 'static,
signal: impl Future<Item = ()> + Send + 'static
) -> (SocketAddr, impl Future<Item = (), Error = ()> + 'static)
[src]
pub fn bind_with_graceful_shutdown(
self,
addr: impl Into<SocketAddr> + 'static,
signal: impl Future<Item = ()> + Send + 'static
) -> (SocketAddr, impl Future<Item = (), Error = ()> + 'static)
Create a server with graceful shutdown signal.
When the signal completes, the server will start the graceful shutdown process.
Returns the bound address and a Future
that can be executed on
any runtime.
Example
extern crate futures; extern crate warp; use futures::sync::oneshot; use warp::Filter; let routes = warp::any() .map(|| "Hello, World!"); let (tx, rx) = oneshot::channel(); let (addr, server) = warp::serve(routes) .bind_with_graceful_shutdown(([127, 0, 0, 1], 3030), rx); // Spawn the server into a runtime warp::spawn(server); // Later, start the shutdown... let _ = tx.send(());
pub fn serve_incoming<I>(
self,
incoming: I
) -> impl Future<Item = (), Error = ()> + 'static where
I: Stream + Send + 'static,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
I::Error: Into<Box<Error + Send + Sync>>,
[src]
pub fn serve_incoming<I>(
self,
incoming: I
) -> impl Future<Item = (), Error = ()> + 'static where
I: Stream + Send + 'static,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
I::Error: Into<Box<Error + Send + Sync>>,
Setup this Server
with a specific stream of incoming connections.
This can be used for Unix Domain Sockets, or TLS, etc.
Returns a Future
that can be executed on any runtime.