Struct choices::warp::Server [−][src]
pub struct Server<F> { /* fields omitted */ }
A Warp Server ready to filter requests.
Implementations
impl<F> Server<F> where
F: Filter + Clone + Send + Sync + 'static,
<<F as FilterBase>::Future as TryFuture>::Ok: Reply,
<<F as FilterBase>::Future as TryFuture>::Error: IsReject,
[src]
impl<F> Server<F> where
F: Filter + Clone + Send + Sync + 'static,
<<F as FilterBase>::Future as TryFuture>::Ok: Reply,
<<F as FilterBase>::Future as TryFuture>::Error: IsReject,
[src]pub async fn run(self, addr: impl Into<SocketAddr>)
[src]
pub async fn run(self, addr: impl Into<SocketAddr>)
[src]Run this Server
forever on the current thread.
pub async fn run_incoming<I>(self, incoming: I) where
I: TryStream + Send,
<I as TryStream>::Ok: AsyncRead,
<I as TryStream>::Ok: AsyncWrite,
<I as TryStream>::Ok: Send,
<I as TryStream>::Ok: 'static,
<I as TryStream>::Ok: Unpin,
<I as TryStream>::Error: Into<Box<dyn Error + 'static + Send + Sync, Global>>,
[src]
pub async fn run_incoming<I>(self, incoming: I) where
I: TryStream + Send,
<I as TryStream>::Ok: AsyncRead,
<I as TryStream>::Ok: AsyncWrite,
<I as TryStream>::Ok: Send,
<I as TryStream>::Ok: 'static,
<I as TryStream>::Ok: Unpin,
<I as TryStream>::Error: Into<Box<dyn Error + 'static + Send + Sync, Global>>,
[src]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<Output = ()> + 'static
[src]
pub fn bind(
self,
addr: impl Into<SocketAddr> + 'static
) -> impl Future<Output = ()> + 'static
[src]Bind to a socket address, returning a Future
that can be
executed on any runtime.
Panics
Panics if we are unable to bind to the provided address.
pub async fn try_bind(self, addr: impl Into<SocketAddr>)
[src]
pub async fn try_bind(self, addr: impl Into<SocketAddr>)
[src]Bind to a socket address, returning a Future
that can be
executed on any runtime.
In case we are unable to bind to the specified address, resolves to an error and logs the reason.
pub fn bind_ephemeral(
self,
addr: impl Into<SocketAddr>
) -> (SocketAddr, impl Future<Output = ()> + 'static)
[src]
pub fn bind_ephemeral(
self,
addr: impl Into<SocketAddr>
) -> (SocketAddr, impl Future<Output = ()> + 'static)
[src]Bind to a possibly ephemeral socket address.
Returns the bound address and a Future
that can be executed on
any runtime.
Panics
Panics if we are unable to bind to the provided address.
pub fn try_bind_ephemeral(
self,
addr: impl Into<SocketAddr>
) -> Result<(SocketAddr, impl Future<Output = ()> + 'static), Error>
[src]
pub fn try_bind_ephemeral(
self,
addr: impl Into<SocketAddr>
) -> Result<(SocketAddr, impl Future<Output = ()> + 'static), Error>
[src]Tried to bind a possibly ephemeral socket address.
Returns a Result
which fails in case we are unable to bind with the
underlying error.
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<Output = ()> + Send + 'static
) -> (SocketAddr, impl Future<Output = ()> + 'static)
[src]
pub fn bind_with_graceful_shutdown(
self,
addr: impl Into<SocketAddr> + 'static,
signal: impl Future<Output = ()> + Send + 'static
) -> (SocketAddr, impl Future<Output = ()> + 'static)
[src]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
use warp::Filter; use futures::future::TryFutureExt; use tokio::sync::oneshot; 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), async { rx.await.ok(); }); // Spawn the server into a runtime tokio::task::spawn(server); // Later, start the shutdown... let _ = tx.send(());
pub fn try_bind_with_graceful_shutdown(
self,
addr: impl Into<SocketAddr> + 'static,
signal: impl Future<Output = ()> + Send + 'static
) -> Result<(SocketAddr, impl Future<Output = ()> + 'static), Error>
[src]
pub fn try_bind_with_graceful_shutdown(
self,
addr: impl Into<SocketAddr> + 'static,
signal: impl Future<Output = ()> + Send + 'static
) -> Result<(SocketAddr, impl Future<Output = ()> + 'static), Error>
[src]Create a server with graceful shutdown signal.
When the signal completes, the server will start the graceful shutdown process.
pub fn serve_incoming<I>(self, incoming: I) -> impl Future<Output = ()> where
I: TryStream + Send,
<I as TryStream>::Ok: AsyncRead,
<I as TryStream>::Ok: AsyncWrite,
<I as TryStream>::Ok: Send,
<I as TryStream>::Ok: 'static,
<I as TryStream>::Ok: Unpin,
<I as TryStream>::Error: Into<Box<dyn Error + 'static + Send + Sync, Global>>,
[src]
pub fn serve_incoming<I>(self, incoming: I) -> impl Future<Output = ()> where
I: TryStream + Send,
<I as TryStream>::Ok: AsyncRead,
<I as TryStream>::Ok: AsyncWrite,
<I as TryStream>::Ok: Send,
<I as TryStream>::Ok: 'static,
<I as TryStream>::Ok: Unpin,
<I as TryStream>::Error: Into<Box<dyn Error + 'static + Send + Sync, Global>>,
[src]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.
pub fn serve_incoming_with_graceful_shutdown<I>(
self,
incoming: I,
signal: impl Future<Output = ()> + Send + 'static
) -> impl Future<Output = ()> where
I: TryStream + Send,
<I as TryStream>::Ok: AsyncRead,
<I as TryStream>::Ok: AsyncWrite,
<I as TryStream>::Ok: Send,
<I as TryStream>::Ok: 'static,
<I as TryStream>::Ok: Unpin,
<I as TryStream>::Error: Into<Box<dyn Error + 'static + Send + Sync, Global>>,
[src]
pub fn serve_incoming_with_graceful_shutdown<I>(
self,
incoming: I,
signal: impl Future<Output = ()> + Send + 'static
) -> impl Future<Output = ()> where
I: TryStream + Send,
<I as TryStream>::Ok: AsyncRead,
<I as TryStream>::Ok: AsyncWrite,
<I as TryStream>::Ok: Send,
<I as TryStream>::Ok: 'static,
<I as TryStream>::Ok: Unpin,
<I as TryStream>::Error: Into<Box<dyn Error + 'static + Send + Sync, Global>>,
[src]Setup this Server
with a specific stream of incoming connections and a
signal to initiate graceful shutdown.
This can be used for Unix Domain Sockets, or TLS, etc.
When the signal completes, the server will start the graceful shutdown process.
Returns a Future
that can be executed on any runtime.
Trait Implementations
Auto Trait Implementations
impl<F> RefUnwindSafe for Server<F> where
F: RefUnwindSafe,
F: RefUnwindSafe,
impl<F> Send for Server<F> where
F: Send,
F: Send,
impl<F> Sync for Server<F> where
F: Sync,
F: Sync,
impl<F> Unpin for Server<F> where
F: Unpin,
F: Unpin,
impl<F> UnwindSafe for Server<F> where
F: UnwindSafe,
F: UnwindSafe,
Blanket Implementations
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,