Struct warp::filter::boxed::BoxedFilter

source ·
pub struct BoxedFilter<T: Tuple> {
    filter: Arc<dyn Filter<Extract = T, Error = Rejection, Future = Pin<Box<dyn Future<Output = Result<T, Rejection>> + Send>>> + Send + Sync>,
}
Expand description

A type representing a boxed Filter trait object.

The filter inside is a dynamic trait object. The purpose of this type is to ease returning Filters from other functions.

To create one, call Filter::boxed on any filter.

§Examples

use warp::{Filter, filters::BoxedFilter, Reply};

pub fn assets_filter() -> BoxedFilter<(impl Reply,)> {
    warp::path("assets")
        .and(warp::fs::dir("./assets"))
        .boxed()
}

Fields§

§filter: Arc<dyn Filter<Extract = T, Error = Rejection, Future = Pin<Box<dyn Future<Output = Result<T, Rejection>> + Send>>> + Send + Sync>

Implementations§

source§

impl<T: Tuple + Send> BoxedFilter<T>

source

pub(super) fn new<F>(filter: F) -> BoxedFilter<T>
where F: Filter<Extract = T> + Send + Sync + 'static, F::Error: Into<Rejection>,

Trait Implementations§

source§

impl<T: Tuple> Clone for BoxedFilter<T>

source§

fn clone(&self) -> BoxedFilter<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Tuple> Debug for BoxedFilter<T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<T: Tuple + Send> FilterBase for BoxedFilter<T>

§

type Extract = T

§

type Error = Rejection

§

type Future = Pin<Box<dyn Future<Output = Result<T, Rejection>> + Send>>

source§

fn filter(&self, _: Internal) -> Self::Future

source§

fn map_err<F, E>(self, _internal: Internal, fun: F) -> MapErr<Self, F>
where Self: Sized, F: Fn(Self::Error) -> E + Clone, E: Debug + Send,

Auto Trait Implementations§

§

impl<T> Freeze for BoxedFilter<T>

§

impl<T> !RefUnwindSafe for BoxedFilter<T>

§

impl<T> Send for BoxedFilter<T>

§

impl<T> Sync for BoxedFilter<T>

§

impl<T> Unpin for BoxedFilter<T>

§

impl<T> !UnwindSafe for BoxedFilter<T>

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> Filter for T
where T: FilterBase,

source§

fn and<F>(self, other: F) -> And<Self, F>
where Self: Sized, <Self::Extract as Tuple>::HList: Combine<<F::Extract as Tuple>::HList>, F: Filter + Clone, F::Error: CombineRejection<Self::Error>,

Composes a new Filter that requires both this and the other to filter a request. Read more
source§

fn or<F>(self, other: F) -> Or<Self, F>
where Self: Filter<Error = Rejection> + Sized, F: Filter, F::Error: CombineRejection<Self::Error>,

Composes a new Filter of either this or the other filter. Read more
source§

fn map<F>(self, fun: F) -> Map<Self, F>
where Self: Sized, F: Func<Self::Extract> + Clone,

Composes this Filter with a function receiving the extracted value. Read more
source§

fn then<F>(self, fun: F) -> Then<Self, F>
where Self: Sized, F: Func<Self::Extract> + Clone, F::Output: Future + Send,

Composes this Filter with an async function receiving the extracted value. Read more
source§

fn and_then<F>(self, fun: F) -> AndThen<Self, F>
where Self: Sized, F: Func<Self::Extract> + Clone, F::Output: TryFuture + Send, <F::Output as TryFuture>::Error: CombineRejection<Self::Error>,

Composes this Filter with a fallible async function receiving the extracted value. Read more
source§

fn or_else<F>(self, fun: F) -> OrElse<Self, F>
where Self: Filter<Error = Rejection> + Sized, F: Func<Rejection>, F::Output: TryFuture<Ok = Self::Extract> + Send, <F::Output as TryFuture>::Error: IsReject,

Compose this Filter with a function receiving an error. Read more
source§

fn recover<F>(self, fun: F) -> Recover<Self, F>
where Self: Filter<Error = Rejection> + Sized, F: Func<Rejection>, F::Output: TryFuture + Send, <F::Output as TryFuture>::Error: IsReject,

Compose this Filter with a function receiving an error and returning a new type, instead of the same type. Read more
source§

fn unify<T>(self) -> Unify<Self>
where Self: Filter<Extract = (Either<T, T>,)> + Sized, T: Tuple,

Unifies the extracted value of Filters composed with or. Read more
source§

fn untuple_one<T>(self) -> UntupleOne<Self>
where Self: Filter<Extract = (T,)> + Sized, T: Tuple,

Convenience method to remove one layer of tupling. Read more
source§

fn with<W>(self, wrapper: W) -> W::Wrapped
where Self: Sized, W: Wrap<Self>,

Wraps the current filter with some wrapper. Read more
source§

fn boxed(self) -> BoxedFilter<Self::Extract>
where Self: Sized + Send + Sync + 'static, Self::Extract: Send, Self::Error: Into<Rejection>,

Boxes this filter into a trait object, making it easier to name the type. 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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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<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
source§

impl<T> FilterClone for T
where T: Filter + Clone,