pub enum State {
    Before(Box<Request>),
    After(Box<Response>),
    Empty,
}
Expand description

State of the Http context. It represent whether the context is used Before(..) or After(..) calling the handler responsible of generating a responder. Empty will be the state of a context when the request is being processed by the handler, or when its original state has been moved by using take & take unchecked methods

Variants§

§

Before(Box<Request>)

§

After(Box<Response>)

§

Empty

Implementations§

source§

impl State

source

pub fn take(&mut self) -> Self

Take the current context leaving State::Empty behind

source

pub fn take_request(&mut self) -> Option<Request>

Take the current request leaving State::Empty behind Returns Some(Request) if the state was Before or None if it was something else

source

pub fn take_request_unchecked(&mut self) -> Request

Take the current request leaving State::Empty behind

Panics

Panics if the state is not Before

source

pub fn take_response(&mut self) -> Option<Response>

Take the current response leaving State::Empty behind Returns Some(Response) if the state was After or None if it was something else

source

pub fn take_response_unchecked(&mut self) -> Response

Take the current response leaving State::Empty behind

Panics

Panics if the state is not After

source

pub fn request(&self) -> Option<&Request>

Returns Some of the current request if state if Before

source

pub fn request_mut(&mut self) -> Option<&Request>

Returns Some of the current request as a mutable ref if state if Before

source

pub fn request_unchecked(&self) -> &Request

Returns the current request

Panics

Panics if state is not Before

source

pub fn request_unchecked_mut(&mut self) -> &mut Request

Returns the current request as a mutable ref

Panics

panics if state is not Before

source

pub fn response(&self) -> Option<&Response>

Returns Some of the current response if state if After

source

pub fn response_mut(&mut self) -> Option<&mut Response>

Returns Some of the current response as a mutable ref if state if After

source

pub fn response_unchecked(&self) -> &Response

Returns the current response

Panics

Panics if state is not After

source

pub fn response_unchecked_mut(&mut self) -> &mut Response

Returns the current response as a mutable ref

Panics

Panics if state is not After

Trait Implementations§

source§

impl Default for State

source§

fn default() -> State

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl !UnwindSafe for State

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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 Twhere U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · 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