pub struct MiddlewareBackend { /* private fields */ }Expand description
An HttpBackend that runs an ordered chain of Middleware around an inner backend.
The first middleware in the chain runs outermost (see this module’s docs for ordering and
composability). It takes effect only when a caller wraps their backend in it and installs it via
Client::with_backend.
Implementations§
Source§impl MiddlewareBackend
impl MiddlewareBackend
Sourcepub fn new(inner: Arc<dyn HttpBackend>) -> Self
pub fn new(inner: Arc<dyn HttpBackend>) -> Self
Start a chain around inner with no middlewares; add them with Self::layer.
Sourcepub fn with_middlewares(
inner: Arc<dyn HttpBackend>,
middlewares: Vec<Arc<dyn Middleware>>,
) -> Self
pub fn with_middlewares( inner: Arc<dyn HttpBackend>, middlewares: Vec<Arc<dyn Middleware>>, ) -> Self
Wrap inner with a pre-built ordered list of middlewares (index 0 runs outermost).
Sourcepub fn layer(self, middleware: Arc<dyn Middleware>) -> Self
pub fn layer(self, middleware: Arc<dyn Middleware>) -> Self
Append a middleware to the chain and return self, for builder-style construction. Each
appended middleware runs inside the ones added before it (the first added is outermost).
Sourcepub fn inner(&self) -> &Arc<dyn HttpBackend> ⓘ
pub fn inner(&self) -> &Arc<dyn HttpBackend> ⓘ
The wrapped inner backend.
Sourcepub fn middlewares(&self) -> &[Arc<dyn Middleware>]
pub fn middlewares(&self) -> &[Arc<dyn Middleware>]
The middleware chain, in run order (index 0 is outermost).
Trait Implementations§
Source§impl Clone for MiddlewareBackend
impl Clone for MiddlewareBackend
Source§fn clone(&self) -> MiddlewareBackend
fn clone(&self) -> MiddlewareBackend
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MiddlewareBackend
impl Debug for MiddlewareBackend
Source§impl HttpBackend for MiddlewareBackend
impl HttpBackend for MiddlewareBackend
Source§fn execute(&self, request: Request<HttpBody>) -> ExecuteFuture<'_>
fn execute(&self, request: Request<HttpBody>) -> ExecuteFuture<'_>
Execute a prepared request, yielding the raw response or a transport failure. The request’s
URI is absolute. A backend that fails builds its
TransportError with the constructor
naming the failure’s class, so the runtime’s send maps it to the right super::Error
variant. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for MiddlewareBackend
impl !UnwindSafe for MiddlewareBackend
impl Freeze for MiddlewareBackend
impl Send for MiddlewareBackend
impl Sync for MiddlewareBackend
impl Unpin for MiddlewareBackend
impl UnsafeUnpin for MiddlewareBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Consume a handle, getting back the initial
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more