FromContext

Trait FromContext 

Source
pub trait FromContext: Sized {
    type Rejection: IntoResponse;

    // Required method
    fn from_context(
        cx: &mut ServerContext,
        parts: &mut Parts,
    ) -> impl Future<Output = Result<Self, Self::Rejection>> + Send;
}
Available on crate feature server only.
Expand description

Extract a type from context (ServerContext and Parts)

This trait is used for handlers, which can extract something from ServerContext and Request.

FromContext only borrows ServerContext and Parts. If your extractor needs to consume Parts or the whole Request, please use FromRequest instead.

Required Associated Types§

Source

type Rejection: IntoResponse

If the extractor fails, it will return this Rejection type.

The Rejection should implement IntoResponse. If extractor fails in handler, the rejection will be converted into a Response and returned.

Required Methods§

Source

fn from_context( cx: &mut ServerContext, parts: &mut Parts, ) -> impl Future<Output = Result<Self, Self::Rejection>> + Send

Extract the type from context.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FromContext for Address

Source§

type Rejection = Infallible

Source§

async fn from_context( cx: &mut ServerContext, _parts: &mut Parts, ) -> Result<Address, Self::Rejection>

Source§

impl FromContext for Method

Source§

type Rejection = Infallible

Source§

async fn from_context( _cx: &mut ServerContext, parts: &mut Parts, ) -> Result<Method, Self::Rejection>

Source§

impl FromContext for Uri

Source§

type Rejection = Infallible

Source§

async fn from_context( _cx: &mut ServerContext, parts: &mut Parts, ) -> Result<Uri, Self::Rejection>

Source§

impl<T> FromContext for Option<T>
where T: FromContext,

Source§

type Rejection = Infallible

Source§

async fn from_context( cx: &mut ServerContext, parts: &mut Parts, ) -> Result<Self, Self::Rejection>

Source§

impl<T> FromContext for Result<T, T::Rejection>
where T: FromContext,

Source§

type Rejection = Infallible

Source§

async fn from_context( cx: &mut ServerContext, parts: &mut Parts, ) -> Result<Self, Self::Rejection>

Implementors§

Source§

impl FromContext for CookieJar

Available on crate feature cookie only.
Source§

impl FromContext for PathParamsMap

Source§

impl FromContext for PathParamsVec

Source§

impl FromContext for ClientIp

Source§

impl FromContext for WebSocketUpgrade<DefaultOnFailedUpgrade>

Available on crate feature ws only.
Source§

impl FromContext for FullUri

Source§

impl<T1> FromContext for PathParams<(T1,)>
where T1: FromPathParam,

Source§

impl<T1, T2> FromContext for PathParams<(T1, T2)>
where T1: FromPathParam, T2: FromPathParam,

Source§

impl<T1, T2, T3> FromContext for PathParams<(T1, T2, T3)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam,

Source§

impl<T1, T2, T3, T4> FromContext for PathParams<(T1, T2, T3, T4)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5> FromContext for PathParams<(T1, T2, T3, T4, T5)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5, T6> FromContext for PathParams<(T1, T2, T3, T4, T5, T6)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam, T6: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5, T6, T7> FromContext for PathParams<(T1, T2, T3, T4, T5, T6, T7)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam, T6: FromPathParam, T7: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8> FromContext for PathParams<(T1, T2, T3, T4, T5, T6, T7, T8)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam, T6: FromPathParam, T7: FromPathParam, T8: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9> FromContext for PathParams<(T1, T2, T3, T4, T5, T6, T7, T8, T9)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam, T6: FromPathParam, T7: FromPathParam, T8: FromPathParam, T9: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> FromContext for PathParams<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam, T6: FromPathParam, T7: FromPathParam, T8: FromPathParam, T9: FromPathParam, T10: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> FromContext for PathParams<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam, T6: FromPathParam, T7: FromPathParam, T8: FromPathParam, T9: FromPathParam, T10: FromPathParam, T11: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> FromContext for PathParams<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam, T6: FromPathParam, T7: FromPathParam, T8: FromPathParam, T9: FromPathParam, T10: FromPathParam, T11: FromPathParam, T12: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> FromContext for PathParams<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam, T6: FromPathParam, T7: FromPathParam, T8: FromPathParam, T9: FromPathParam, T10: FromPathParam, T11: FromPathParam, T12: FromPathParam, T13: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> FromContext for PathParams<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam, T6: FromPathParam, T7: FromPathParam, T8: FromPathParam, T9: FromPathParam, T10: FromPathParam, T11: FromPathParam, T12: FromPathParam, T13: FromPathParam, T14: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> FromContext for PathParams<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam, T6: FromPathParam, T7: FromPathParam, T8: FromPathParam, T9: FromPathParam, T10: FromPathParam, T11: FromPathParam, T12: FromPathParam, T13: FromPathParam, T14: FromPathParam, T15: FromPathParam,

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> FromContext for PathParams<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)>
where T1: FromPathParam, T2: FromPathParam, T3: FromPathParam, T4: FromPathParam, T5: FromPathParam, T6: FromPathParam, T7: FromPathParam, T8: FromPathParam, T9: FromPathParam, T10: FromPathParam, T11: FromPathParam, T12: FromPathParam, T13: FromPathParam, T14: FromPathParam, T15: FromPathParam, T16: FromPathParam,

Source§

impl<T> FromContext for Extension<T>
where T: Clone + Send + Sync + 'static,

Source§

type Rejection = ExtensionRejection

Source§

impl<T> FromContext for PathParams<T>
where T: FromPathParam,

Source§

impl<T> FromContext for Query<T>

Available on crate feature query only.