Struct AddExtension

pub struct AddExtension<S, T> { /* private fields */ }

Middleware for adding some shareable value to request extensions.

See Passing state from middleware to handlers for more details.

If you need a layer to add an extension to every request, use the Layer implementation of [Extension].

Trait Implementations

impl<ResBody, S, T> Service<Request<ResBody>> for AddExtension<S, T> where S: Service<Request<ResBody>>, T: Clone + Send + Sync + 'static,

type Response = <S as Service<Request<ResBody>>>::Response;
type Error = <S as Service<Request<ResBody>>>::Error;
type Future = <S as Service<Request<ResBody>>>::Future;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<ResBody>) -> Self::Future

impl<S: Clone, T: Clone> Clone for AddExtension<S, T>

fn clone(&self) -> AddExtension<S, T>

impl<S: Copy, T: Copy> Copy for AddExtension<S, T>

impl<S: Debug, T: Debug> Debug for AddExtension<S, T>

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

Auto Trait Implementations

impl<S, T> Freeze for AddExtension<S, T> where S: Freeze, T: Freeze,

impl<S, T> RefUnwindSafe for AddExtension<S, T> where S: RefUnwindSafe, T: RefUnwindSafe,

impl<S, T> Send for AddExtension<S, T> where S: Send, T: Send,

impl<S, T> Sync for AddExtension<S, T> where S: Sync, T: Sync,

impl<S, T> Unpin for AddExtension<S, T> where S: Unpin, T: Unpin,

impl<S, T> UnsafeUnpin for AddExtension<S, T> where S: UnsafeUnpin, T: UnsafeUnpin,

impl<S, T> UnwindSafe for AddExtension<S, T> where S: UnwindSafe, T: UnwindSafe,

Blanket Implementations

impl<C, Target> MakeConnection<Target> for AddExtension<S, T> where C: Service<Target>, <C as Service<Target>>::Response: AsyncRead + AsyncWrite,

type Connection = <C as Service<Target>>::Response;
type Error = <C as Service<Target>>::Error;
type Future = <C as Service<Target>>::Future;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <C as MakeConnection<Target>>::Error>>
fn make_connection(&mut self, target: Target) -> <C as MakeConnection<Target>>::Future

impl<M, S, Target, Request> MakeService<Target, Request> for AddExtension<S, T> where M: Service<Target, Response = S>, S: Service<Request>,

type Response = <S as Service<Request>>::Response;
type Error = <S as Service<Request>>::Error;
type Service = S;
type MakeError = <M as Service<Target>>::Error;
type Future = <M as Service<Target>>::Future;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
fn make_service(&mut self, target: Target) -> <M as MakeService<Target, Request>>::Future

impl<S, R> ServiceExt<R> for AddExtension<S, T> where S: Service<R>,

fn into_make_service(self) -> IntoMakeService<S>
fn into_make_service_with_connect_info<C>(self) -> IntoMakeServiceWithConnectInfo<S, C>

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for AddExtension<S, T> where ST: ?Sized, DT: ?Sized,

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for AddExtension<S, T> where ST: ?Sized, DT: ?Sized,

impl<T> Any for AddExtension<S, T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for AddExtension<S, T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for AddExtension<S, T> where T: ?Sized,

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

impl<T> CloneToUninit for AddExtension<S, T> where T: Clone,

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

impl<T> From<T> for AddExtension<S, T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> FromRef<T> for AddExtension<S, T> where T: Clone,

fn from_ref(input: &T) -> T

impl<T> Instrument for AddExtension<S, T>

impl<T> Read<Exclusive, BecauseExclusive> for AddExtension<S, T> where T: ?Sized,

impl<T> Same for AddExtension<S, T>

type Output = T;

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> WithSubscriber for AddExtension<S, T>

impl<T, Request> ServiceExt<Request> for AddExtension<S, T> where T: Service<Request> + ?Sized,

impl<T, U> Into<U> for AddExtension<S, T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for AddExtension<S, T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for AddExtension<S, T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

impl<V, T> VZip<V> for AddExtension<S, T> where V: MultiLane<T>,

fn vzip(self) -> V