[−][src]Struct warp::Server
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]
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]
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<dyn StdError + Send + Sync>>,
[src]
I: Stream + Send + 'static,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
I::Error: Into<Box<dyn StdError + 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]
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.
Panics
Panics if we are unable to bind to the provided address.
pub fn try_bind(
self,
addr: impl Into<SocketAddr> + 'static
) -> impl Future<Item = (), Error = ()> + 'static
[src]
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.
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> + 'static
) -> (SocketAddr, impl Future<Item = (), Error = ()> + 'static)
[src]
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.
Panics
Panics if we are unable to bind to the provided address.
pub fn try_bind_ephemeral(
self,
addr: impl Into<SocketAddr> + 'static
) -> Result<(SocketAddr, impl Future<Item = (), Error = ()> + 'static), Error>
[src]
self,
addr: impl Into<SocketAddr> + 'static
) -> Result<(SocketAddr, impl Future<Item = (), Error = ()> + 'static), Error>
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<Item = ()> + Send + 'static
) -> (SocketAddr, impl Future<Item = (), Error = ()> + 'static)
[src]
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<dyn StdError + Send + Sync>>,
[src]
self,
incoming: I
) -> impl Future<Item = (), Error = ()> + 'static where
I: Stream + Send + 'static,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
I::Error: Into<Box<dyn StdError + 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.
pub fn tls(self, cert: impl AsRef<Path>, key: impl AsRef<Path>) -> TlsServer<S>
[src]
Configure a server to use TLS with the supplied certificate and key files.
This function requires the "tls"
feature.
Trait Implementations
Auto Trait Implementations
impl<S> Send for Server<S> where
S: Send,
S: Send,
impl<S> Unpin for Server<S> where
S: Unpin,
S: Unpin,
impl<S> Sync for Server<S> where
S: Sync,
S: Sync,
impl<S> UnwindSafe for Server<S> where
S: UnwindSafe,
S: UnwindSafe,
impl<S> RefUnwindSafe for Server<S> where
S: RefUnwindSafe,
S: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Erased for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,