Struct Server

Source
pub struct Server<F, A, R> { /* private fields */ }
Available on crate feature server and docsrs only.
Expand description

A warp Server ready to filter requests.

Construct this type using serve().

§Unnameable

This type is publicly available in the docs only.

It is not otherwise nameable, since it is a builder type using typestate to allow for ergonomic configuration.

Implementations§

Source§

impl<F, R> Server<F, LazyTcp, R>
where F: Filter + Clone + Send + Sync + 'static, <F::Future as TryFuture>::Ok: Reply, <F::Future as TryFuture>::Error: IsReject, R: Run,

Source

pub async fn run(self, addr: impl Into<SocketAddr>)

Binds and runs this server.

§Panics

Panics if we are unable to bind to the provided address.

To handle bind failures, bind a listener and call incoming().

Source

pub async fn bind( self, addr: impl Into<SocketAddr>, ) -> Server<F, TcpListener, R>

Binds this server.

§Panics

Panics if we are unable to bind to the provided address.

To handle bind failures, bind a listener and call incoming().

Source

pub fn incoming<A>(self, acceptor: A) -> Server<F, A, R>

Configure the server with an acceptor of incoming connections.

Source§

impl<F, A, R> Server<F, A, R>
where F: Filter + Clone + Send + Sync + 'static, <F::Future as TryFuture>::Ok: Reply, <F::Future as TryFuture>::Error: IsReject, A: Accept, R: Run,

Source

pub fn graceful<Fut>(self, shutdown_signal: Fut) -> Server<F, A, Graceful<Fut>>
where Fut: Future<Output = ()> + Send + 'static,

Add graceful shutdown support to this server.

§Example
warp::serve(filter)
    .bind(addr).await
    .graceful(async {
        // some signal in here, such as ctrl_c
    })
    .run().await;
Source

pub async fn run(self)

Run this server.

Trait Implementations§

Source§

impl<F: Debug, A: Debug, R: Debug> Debug for Server<F, A, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<F, A, R> Freeze for Server<F, A, R>
where A: Freeze, F: Freeze, R: Freeze,

§

impl<F, A, R> RefUnwindSafe for Server<F, A, R>

§

impl<F, A, R> Send for Server<F, A, R>
where A: Send, F: Send, R: Send,

§

impl<F, A, R> Sync for Server<F, A, R>
where A: Sync, F: Sync, R: Sync,

§

impl<F, A, R> Unpin for Server<F, A, R>
where A: Unpin, F: Unpin, R: Unpin,

§

impl<F, A, R> UnwindSafe for Server<F, A, R>
where A: UnwindSafe, F: UnwindSafe, R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more