State

Struct State 

Source
pub struct State<T>(pub T)
where
    T: ?Sized;
Expand description

Extracts state from the extensions of a request.

Tuple Fields§

§0: T

Implementations§

Source§

impl<T> State<T>

Source

pub const fn new(data: T) -> State<T>

Create new State instance.

Source

pub fn into_inner(self) -> T

Consumes the State, returning the wrapped value.

Trait Implementations§

Source§

impl<T> AsRef<T> for State<T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T> Clone for State<T>
where T: Clone + ?Sized,

Source§

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

Returns a duplicate 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> Debug for State<T>
where T: Debug + ?Sized,

Source§

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

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

impl<T> Default for State<T>
where T: Default + ?Sized,

Source§

fn default() -> State<T>

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

impl<T> Deref for State<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T> DerefMut for State<T>

Source§

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

Mutably dereferences the value.
Source§

impl<T> FromRequest for State<T>
where T: Clone + Send + Sync + 'static,

Source§

type Error = StateError

The type returned in the event of a conversion error.
Source§

async fn extract( req: &mut Request<Body>, ) -> Result<State<T>, <State<T> as FromRequest>::Error>

Extracts this type from the HTTP Request.
Source§

impl<T, H, O> Handler<Request<Body>> for State<(T, H)>
where T: Clone + Send + Sync + 'static, H: Handler<Request<Body>, Output = Result<O, Error>>, O: IntoResponse,

Source§

type Output = Result<Response<Body>, Error>

The returned type after the call operator is used.
Source§

fn call<'life0, 'async_trait>( &'life0 self, req: Request<Body>, ) -> Pin<Box<dyn Future<Output = <State<(T, H)> as Handler<Request<Body>>>::Output> + Send + 'async_trait>>
where 'life0: 'async_trait, State<(T, H)>: 'async_trait,

Performs the call operation.
Source§

impl<H, T> Transform<H> for State<T>
where T: Clone + Send + Sync + 'static,

Source§

type Output = State<(T, H)>

A new handler.
Source§

fn transform(&self, h: H) -> <State<T> as Transform<H>>::Output

Transforms self and wraps Handler to a new handler.
Source§

impl<T> Copy for State<T>
where T: Copy + ?Sized,

Auto Trait Implementations§

§

impl<T> Freeze for State<T>
where T: Freeze + ?Sized,

§

impl<T> RefUnwindSafe for State<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Send for State<T>
where T: Send + ?Sized,

§

impl<T> Sync for State<T>
where T: Sync + ?Sized,

§

impl<T> Unpin for State<T>
where T: Unpin + ?Sized,

§

impl<T> UnwindSafe for State<T>
where T: UnwindSafe + ?Sized,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<I, T> HandlerExt<I> for T
where T: Handler<I> + ?Sized,

Source§

fn before<F>(self, f: F) -> Before<Self, F>
where Self: Sized,

Maps the input before the handler calls.
Source§

fn after<F>(self, f: F) -> After<Self, F>
where Self: Sized,

Maps the output Result<T> after the handler called.
Source§

fn around<F>(self, f: F) -> Around<Self, F>
where Self: Sized,

Wraps around the remaining handler or middleware chain.
Source§

fn either<R>(self, r: R, enable: bool) -> Either<Self, R>
where Self: Sized,

Wraps this handler in an Either handler, making it the left-hand variant of that Either. Read more
Source§

fn map<F>(self, f: F) -> Map<Self, F>
where Self: Sized,

Maps the Ok value of the output if after the handler called.
Source§

fn map_into_response(self) -> MapInToResponse<Self>
where Self: Sized,

Maps the handler’s output type to the Response.
Source§

fn and_then<F>(self, f: F) -> AndThen<Self, F>
where Self: Sized,

Calls op if the result is Ok, otherwise returns the Err value of self.
Source§

fn map_err<F>(self, f: F) -> MapErr<Self, F>
where Self: Sized,

Maps the Err value of the output if after the handler called.
Source§

fn or_else<F>(self, f: F) -> OrElse<Self, F>
where Self: Sized,

Calls op if the output is Err, otherwise returns the Ok value of the output.
Source§

fn catch_error<F, E, R>(self, f: F) -> CatchError<Self, F, E, R>
where Self: Sized,

Catches rejected error while calling the handler.
Source§

fn catch_unwind<F>(self, f: F) -> CatchUnwind<Self, F>
where Self: Sized,

Catches unwinding panics while calling the handler.
Source§

fn boxed(self) -> BoxHandler<I, Self::Output>
where Self: Sized + Clone,

Converts this Handler into a BoxHandler.
Source§

fn with<T>(self, t: T) -> <T as Transform<Self>>::Output
where T: Transform<Self>, Self: Sized,

Returns a new Handler that wrapping the Self and a type implementing Transform.
Source§

fn with_fn<F>(self, f: F) -> Self
where F: Fn(Self) -> Self, Self: Sized,

Maps the handler.
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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

impl<T> Formattable for T
where T: Deref, <T as Deref>::Target: Formattable,

Source§

impl<T> Parsable for T
where T: Deref, <T as Deref>::Target: Parsable,