pub struct Middleware<State, CTX: Debug, Request: Debug, Response: Debug, Error> { /* private fields */ }Implementations§
Source§impl<State: 'static + Send + Sync, CTX: 'static + Send + Sync + Debug, Request: 'static + Send + Sync + Debug, Response: 'static + Send + Sync + Debug, Error: 'static + Send + Sync> Middleware<State, CTX, Request, Response, Error>
impl<State: 'static + Send + Sync, CTX: 'static + Send + Sync + Debug, Request: 'static + Send + Sync + Debug, Response: 'static + Send + Sync + Debug, Error: 'static + Send + Sync> Middleware<State, CTX, Request, Response, Error>
Sourcepub fn new(
middleware: Vec<Box<dyn MiddlewareChain<State, CTX, Request, Response, Error>>>,
) -> Self
pub fn new( middleware: Vec<Box<dyn MiddlewareChain<State, CTX, Request, Response, Error>>>, ) -> Self
Create a new Middleware execution chain.
§Panics
This function will panic if the provided middleware vector is empty,
as an empty chain cannot be unwrapped into an execution target.
Sourcepub async fn call(
&self,
state: State,
ctx: CTX,
request: Request,
) -> Result<Context<CTX, Request, Response>, Error>
pub async fn call( &self, state: State, ctx: CTX, request: Request, ) -> Result<Context<CTX, Request, Response>, Error>
Executes the middleware chain for the given request.
§Errors
Returns an error if any MiddlewareChain in the execution pipeline fails
while processing the state or request context.
Auto Trait Implementations§
impl<State, CTX, Request, Response, Error> !RefUnwindSafe for Middleware<State, CTX, Request, Response, Error>
impl<State, CTX, Request, Response, Error> !UnwindSafe for Middleware<State, CTX, Request, Response, Error>
impl<State, CTX, Request, Response, Error> Freeze for Middleware<State, CTX, Request, Response, Error>
impl<State, CTX, Request, Response, Error> Send for Middleware<State, CTX, Request, Response, Error>
impl<State, CTX, Request, Response, Error> Sync for Middleware<State, CTX, Request, Response, Error>
impl<State, CTX, Request, Response, Error> Unpin for Middleware<State, CTX, Request, Response, Error>
impl<State, CTX, Request, Response, Error> UnsafeUnpin for Middleware<State, CTX, Request, Response, Error>
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
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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