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§
Sourcetype Rejection: IntoResponse
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§
Sourcefn from_context(
cx: &mut ServerContext,
parts: &mut Parts,
) -> impl Future<Output = Result<Self, Self::Rejection>> + Send
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
impl FromContext for Address
type Rejection = Infallible
async fn from_context( cx: &mut ServerContext, _parts: &mut Parts, ) -> Result<Address, Self::Rejection>
Source§impl FromContext for Method
impl FromContext for Method
type Rejection = Infallible
async fn from_context( _cx: &mut ServerContext, parts: &mut Parts, ) -> Result<Method, Self::Rejection>
Source§impl FromContext for Uri
impl FromContext for Uri
type Rejection = Infallible
async fn from_context( _cx: &mut ServerContext, parts: &mut Parts, ) -> Result<Uri, Self::Rejection>
Source§impl<T> FromContext for Option<T>where
T: FromContext,
impl<T> FromContext for Option<T>where
T: FromContext,
type Rejection = Infallible
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,
impl<T> FromContext for Result<T, T::Rejection>where
T: FromContext,
type Rejection = Infallible
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.
impl FromContext for CookieJar
Available on crate feature
cookie only.type Rejection = Infallible
Source§impl FromContext for PathParamsMap
impl FromContext for PathParamsMap
type Rejection = Infallible
Source§impl FromContext for PathParamsVec
impl FromContext for PathParamsVec
type Rejection = Infallible
Source§impl FromContext for ClientIp
impl FromContext for ClientIp
type Rejection = Infallible
Source§impl FromContext for WebSocketUpgrade<DefaultOnFailedUpgrade>
Available on crate feature ws only.
impl FromContext for WebSocketUpgrade<DefaultOnFailedUpgrade>
Available on crate feature
ws only.Source§impl<T1> FromContext for PathParams<(T1,)>where
T1: FromPathParam,
impl<T1> FromContext for PathParams<(T1,)>where
T1: FromPathParam,
Source§impl<T1, T2> FromContext for PathParams<(T1, T2)>where
T1: FromPathParam,
T2: FromPathParam,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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>
impl<T> FromContext for Extension<T>
Source§impl<T> FromContext for PathParams<T>where
T: FromPathParam,
impl<T> FromContext for PathParams<T>where
T: FromPathParam,
Source§impl<T> FromContext for Query<T>where
T: DeserializeOwned,
Available on crate feature query only.
impl<T> FromContext for Query<T>where
T: DeserializeOwned,
Available on crate feature
query only.