Struct WebContext

Source
pub struct WebContext<'a, C = (), B = RequestBody> { /* private fields */ }
Expand description

web context type focus on stateful and side effect based request data access.

Implementations§

Source§

impl<'a, C, B> WebContext<'a, C, B>

Source

pub fn reborrow(&mut self) -> WebContext<'_, C, B>

Reborrow Self so the ownership of WebRequest is not lost.

§Note:

Reborrow is not pure and receiver of it can mutate Self in any way they like.

§Example:
// a function need ownership of request but not return it in output.
fn handler(req: WebContext<'_>) -> Result<(), ()> {
    Err(())
}

// use reborrow to avoid pass request by value.
match handler(req.reborrow()) {
    // still able to access request after handler return.
    Ok(_) => assert_eq!(req.state(), &()),
    Err(_) => assert_eq!(req.state(), &())
}
Source

pub async fn extract<'r, T>(&'r self) -> Result<T, T::Error>
where T: FromRequest<'r, Self>,

extract typed data from WebContext. type must impl FromRequest trait. this is a shortcut method that avoiding explicit import of mentioned trait.

§Examples
async fn extract(ctx: WebContext<'_, usize>) {
    // extract state from context.
    let StateRef(state1) = ctx.extract().await.unwrap();

    // equivalent of above method with explicit trait import.
    use xitca_web::handler::FromRequest;
    let StateRef(state2) = StateRef::<'_, usize>::from_request(&ctx).await.unwrap();

    // two extractors will return the same type and data state.
    assert_eq!(state1, state2);
}
Source

pub fn state(&self) -> &C

Get an immutable reference of App state

Source

pub fn req(&self) -> &WebRequest<()>

Get an immutable reference of WebRequest

Source

pub fn req_mut(&mut self) -> &mut WebRequest<()>

Get a mutable reference of WebRequest

Source

pub fn body(&self) -> Ref<'_, B>

Get a immutable reference of RequestBody

Source

pub fn body_borrow_mut(&self) -> RefMut<'_, B>

Get a mutable reference of RequestBody

Source

pub fn body_get_mut(&mut self) -> &mut B

Get a mutable reference of RequestBody This API takes &mut WebRequest so it bypass runtime borrow checker and therefore has zero runtime overhead.

Source

pub fn take_request(&mut self) -> WebRequest<B>
where B: Default,

Source

pub fn into_response<ResB: Into<ResponseBody>>(self, body: ResB) -> WebResponse

Transform self to a WebResponse with given body type.

The heap allocation of request would be re-used.

Source

pub fn as_response<ResB: Into<ResponseBody>>( &mut self, body: ResB, ) -> WebResponse

Transform &mut self to a WebResponse with given body type.

The heap allocation of request would be re-used.

Trait Implementations§

Source§

impl<C, B, T> BorrowReq<T> for WebContext<'_, C, B>

Source§

fn borrow(&self) -> &T

Source§

impl<C, B, T> BorrowReqMut<T> for WebContext<'_, C, B>

Source§

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

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for &'a HeaderMap

Source§

type Type<'b> = &'b HeaderMap

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for &'a Method

Source§

type Type<'b> = &'b Method

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for &'a WebRequest<()>

Source§

type Type<'b> = &'b Request<RequestExt<()>>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for &'a RequestExt<()>

Source§

type Type<'b> = &'b RequestExt<()>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for &'a SocketAddr

Source§

type Type<'b> = &'b SocketAddr

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for &'a Uri

Source§

type Type<'b> = &'b Uri

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for &'a WebContext<'a, C, B>
where C: 'static, B: 'static,

Source§

type Type<'b> = &'b WebContext<'b, C, B>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for ()

Source§

type Type<'b> = ()

Source§

type Error = Error

Source§

async fn from_request(_: &'a WebContext<'r, C, B>) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, const LIMIT: usize> FromRequest<'a, WebContext<'r, C, B>> for (Bytes, Limit<LIMIT>)
where B: BodyStream + Default,

Source§

type Type<'b> = (Bytes, Limit<LIMIT>)

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, const LIMIT: usize> FromRequest<'a, WebContext<'r, C, B>> for (BytesMut, Limit<LIMIT>)
where B: BodyStream + Default,

Source§

type Type<'b> = (BytesMut, Limit<LIMIT>)

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, const LIMIT: usize> FromRequest<'a, WebContext<'r, C, B>> for (Vec<u8>, Limit<LIMIT>)
where B: BodyStream + Default,

Source§

type Type<'b> = (Vec<u8>, Limit<LIMIT>)

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for Body<B>
where B: BodyStream + Default,

Source§

type Type<'b> = Body<B>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for Bytes
where B: BodyStream + Default,

Source§

type Type<'b> = Bytes

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for BytesMut
where B: BodyStream + Default,

Source§

type Type<'b> = BytesMut

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, K> FromRequest<'a, WebContext<'r, C, B>> for CookieJar<K>
where K: for<'a2, 'r2> FromRequest<'a2, WebContext<'r2, C, B>, Error = Error>,

Source§

type Type<'b> = CookieJar<K>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for ExtensionKey

Source§

type Type<'b> = ExtensionKey

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T> FromRequest<'a, WebContext<'r, C, B>> for ExtensionOwn<T>
where T: Send + Sync + Clone + 'static,

Source§

type Type<'b> = ExtensionOwn<T>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T> FromRequest<'a, WebContext<'r, C, B>> for ExtensionRef<'a, T>
where T: Send + Sync + 'static,

Source§

type Type<'b> = ExtensionRef<'b, T>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for ExtensionsRef<'a>

Source§

type Type<'b> = ExtensionsRef<'b>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T, const LIMIT: usize> FromRequest<'a, WebContext<'r, C, B>> for Form<T, LIMIT>
where B: BodyStream + Default, T: for<'de> Deserialize<'de>,

Source§

type Type<'b> = Form<T, LIMIT>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for HeaderMap

Source§

type Type<'b> = HeaderMap

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, const HEADER_NAME: usize> FromRequest<'a, WebContext<'r, C, B>> for HeaderRef<'a, HEADER_NAME>

Source§

type Type<'b> = HeaderRef<'b, HEADER_NAME>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T, const LIMIT: usize> FromRequest<'a, WebContext<'r, C, B>> for Json<T, LIMIT>
where B: BodyStream + Default, T: for<'de> Deserialize<'de>,

Source§

type Type<'b> = Json<T, LIMIT>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T, const LIMIT: usize> FromRequest<'a, WebContext<'r, C, B>> for LazyForm<T, LIMIT>
where B: BodyStream + Default, T: Deserialize<'static>,

Source§

type Type<'b> = LazyForm<T, LIMIT>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T, const LIMIT: usize> FromRequest<'a, WebContext<'r, C, B>> for LazyJson<T, LIMIT>
where B: BodyStream + Default, T: Deserialize<'static>,

Source§

type Type<'b> = LazyJson<T, LIMIT>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T> FromRequest<'a, WebContext<'r, C, B>> for LazyParams<'a, T>

Source§

type Type<'b> = LazyParams<'b, T>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T> FromRequest<'a, WebContext<'r, C, B>> for LazyQuery<'a, T>
where T: Deserialize<'static>,

Source§

type Type<'b> = LazyQuery<'b, T>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for Method

Source§

type Type<'b> = Method

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for Multipart<B>
where B: BodyStream + Default,

Source§

type Type<'b> = Multipart<B>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T> FromRequest<'a, WebContext<'r, C, B>> for Option<T>
where T: FromRequest<'a, WebContext<'r, C, B>>,

Source§

type Type<'b> = Option<<T as FromRequest<'a, WebContext<'r, C, B>>>::Type<'b>>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, T, C, B> FromRequest<'a, WebContext<'r, C, B>> for Params<T>
where T: for<'de> Deserialize<'de>,

Source§

type Type<'b> = Params<T>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for ParamsRef<'a>

Source§

type Type<'b> = ParamsRef<'b>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for PathOwn

Source§

type Type<'b> = PathOwn

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for PathRef<'a>

Source§

type Type<'b> = PathRef<'b>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, K> FromRequest<'a, WebContext<'r, C, B>> for Private<K>
where K: for<'a2, 'r2> FromRequest<'a2, WebContext<'r2, C, B>, Error = Error> + Into<Key>,

Source§

type Type<'b> = Private<K>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T> FromRequest<'a, WebContext<'r, C, B>> for Query<T>
where T: for<'de> Deserialize<'de>,

Source§

type Type<'b> = Query<T>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for WebRequest<()>

Source§

type Type<'b> = Request<RequestExt<()>>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for RequestExt<()>

Source§

type Type<'b> = RequestExt<()>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T, E> FromRequest<'a, WebContext<'r, C, B>> for Result<T, E>
where T: FromRequest<'a, WebContext<'r, C, B>, Error = E>,

Source§

type Type<'b> = Result<<T as FromRequest<'a, WebContext<'r, C, B>>>::Type<'b>, <T as FromRequest<'a, WebContext<'r, C, B>>>::Error>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, K> FromRequest<'a, WebContext<'r, C, B>> for Signed<K>
where K: for<'a2, 'r2> FromRequest<'a2, WebContext<'r2, C, B>, Error = Error> + Into<Key>,

Source§

type Type<'b> = Signed<K>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for SocketAddr

Source§

type Type<'b> = SocketAddr

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for StateKey
where C: Borrow<Self>,

Source§

type Type<'b> = StateKey

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T> FromRequest<'a, WebContext<'r, C, B>> for StateOwn<T>
where C: BorrowState<T>, T: Clone,

Source§

type Type<'b> = StateOwn<T>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B, T> FromRequest<'a, WebContext<'r, C, B>> for StateRef<'a, T>
where C: BorrowState<T>, T: ?Sized + 'static,

Source§

type Type<'b> = StateRef<'b, T>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for String
where B: BodyStream + Default,

Source§

type Type<'b> = String

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for Uri

Source§

type Type<'b> = Uri

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for UriOwn

Source§

type Type<'b> = UriOwn

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for UriRef<'a>

Source§

type Type<'b> = UriRef<'b>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for Vec<u8>
where B: BodyStream + Default,

Source§

type Type<'b> = Vec<u8>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<'a, 'r, C, B> FromRequest<'a, WebContext<'r, C, B>> for WebSocket<B>
where C: 'static, B: BodyStream + Default + 'static,

Source§

type Type<'b> = WebSocket<B>

Source§

type Error = Error

Source§

async fn from_request( ctx: &'a WebContext<'r, C, B>, ) -> Result<Self, Self::Error>

Source§

impl<C, B, I, Res, Err> IntoObject<I, ()> for WebContext<'_, C, B>
where C: 'static, B: 'static, I: Service + RouteGen + Send + Sync + 'static, I::Response: for<'r> Service<WebContext<'r, C, B>, Response = Res, Error = Err> + 'static,

Source§

type Object = RouteObject<(), Box<dyn for<'r> ServiceObject<WebContext<'r, C, B>, Error = Err, Response = Res>>, <I as Service>::Error>

The type-erased form of I.
Source§

fn into_object(inner: I) -> Self::Object

Constructs Self::Object from I.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for &'static str

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B, const N: usize> Responder<WebContext<'r, C, B>> for [(HeaderName, HeaderValue); N]

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for (HeaderName, HeaderValue)

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for Box<str>

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for BoxBody

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for Bytes

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for BytesMut

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B, K> Responder<WebContext<'r, C, B>> for CookieJar<K>

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for Cow<'static, str>

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for Error

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, _: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>
where Self: Sized,

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for ErrorStatus

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, _: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>
where Self: Sized,

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B, T> Responder<WebContext<'r, C, B>> for Form<T>
where T: Serialize,

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for HeaderMap

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B, T> Responder<WebContext<'r, C, B>> for Html<T>
where T: Into<ResponseBody>,

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B, T> Responder<WebContext<'r, C, B>> for Json<T>
where T: Serialize,

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for Redirect

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B, ResB> Responder<WebContext<'r, C, B>> for WebResponse<ResB>

Source§

type Response = Response<ResB>

Source§

type Error = Error

Source§

async fn respond( self, _: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>
where Self: Sized,

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B, ResB> Responder<WebContext<'r, C, B>> for ResponseBody<ResB>

Source§

type Response = Response<ResponseBody<ResB>>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B, T, Res, Err, E> Responder<WebContext<'r, C, B>> for Result<T, E>
where T: for<'r2> Responder<WebContext<'r2, C, B>, Response = Res, Error = Err>, Error: From<E> + From<Err>,

Source§

type Response = Res

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>
where Self: Sized,

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for StatusCode

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for String

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B, T> Responder<WebContext<'r, C, B>> for Text<T>
where T: Into<ResponseBody>,

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for Value

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for Vec<(HeaderName, HeaderValue)>

Source§

type Response = Response<ResponseBody>

Source§

type Error = Error

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for Vec<u8>

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn respond( self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C, B> Responder<WebContext<'r, C, B>> for WebSocket<B>
where B: BodyStream + 'static,

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn respond( self, _: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

generate response from given request.
Source§

fn map(self, res: Self::Response) -> Result<Self::Response, Self::Error>
where Self: Sized,

map response type and mutate it’s state. default to pass through without any modification.
Source§

impl<'r, C> Service<WebContext<'r, C>> for Error
where C: 'static,

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for BodyOverFlow

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Box<dyn Error + Send + Sync>

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for EncodingError

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, req: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Error

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Error

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Error

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Error

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for ErrorStatus

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for ExtensionNotFound

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for FromUtf8Error

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for HandshakeError

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for HeaderNotFound

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B, T> Service<WebContext<'r, C, B>> for Html<T>
where T: Clone + Into<ResponseBody>,

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Error

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Infallible

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, _: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for InvalidHeaderValue

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B, T> Service<WebContext<'r, C, B>> for Json<T>
where T: Serialize + Clone,

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Error

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, S, C, B, Res, Err> Service<WebContext<'r, C, B>> for LimitService<S>
where B: BodyStream + Default, S: for<'r2> Service<WebContext<'r2, C, LimitBody<B>>, Response = Res, Error = Err>,

Source§

type Response = Res

The Ok part of output future.
Source§

type Error = Err

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for MatchError

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for MethodNotAllowed

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for MultipartError

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for ParseError

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Redirect

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Error

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for StatusCode

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B, T> Service<WebContext<'r, C, B>> for Text<T>
where T: Into<ResponseBody> + Clone,

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Error

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for ThreadJoinError

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for ToStrError

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for TooManyRequests

Source§

type Response = Response<ResponseBody>

The Ok part of output future.
Source§

type Error = Infallible

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, ReqB, S, ResB> Service<WebContext<'r, C, ReqB>> for TowerCompatService<S>
where S: Service<Request<CompatReqBody<RequestExt<ReqB>, C>>, Response = Response<ResB>>, ResB: Body, C: Clone + 'static, ReqB: Default,

Source§

type Response = Response<CompatResBody<ResB>>

The Ok part of output future.
Source§

type Error = <S as Service<Request<CompatReqBody<RequestExt<ReqB>, C>>>>::Error

The Err part of output future.
Source§

async fn call( &self, ctx: WebContext<'r, C, ReqB>, ) -> Result<Self::Response, Self::Error>

Auto Trait Implementations§

§

impl<'a, C, B> Freeze for WebContext<'a, C, B>

§

impl<'a, C = (), B = RequestBody> !RefUnwindSafe for WebContext<'a, C, B>

§

impl<'a, C, B> Send for WebContext<'a, C, B>
where C: Sync, B: Send,

§

impl<'a, C = (), B = RequestBody> !Sync for WebContext<'a, C, B>

§

impl<'a, C, B> Unpin for WebContext<'a, C, B>

§

impl<'a, C = (), B = RequestBody> !UnwindSafe for WebContext<'a, C, B>

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> BorrowState<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

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