pub trait Middleware<M: Metadata>:
Send
+ Sync
+ 'static {
type Future: Future<Output = Option<Response>> + Send + 'static;
type CallFuture: Future<Output = Option<Output>> + Send + 'static;
// Provided methods
fn on_request<F, X>(
&self,
request: Request,
meta: M,
next: F,
) -> Either<Self::Future, X> ⓘ
where F: Fn(Request, M) -> X + Send + Sync,
X: Future<Output = Option<Response>> + Send + 'static { ... }
fn on_call<F, X>(
&self,
call: Call,
meta: M,
next: F,
) -> Either<Self::CallFuture, X> ⓘ
where F: Fn(Call, M) -> X + Send + Sync,
X: Future<Output = Option<Output>> + Send + 'static { ... }
}
Expand description
RPC middleware
Required Associated Types§
Provided Methods§
Sourcefn on_request<F, X>(
&self,
request: Request,
meta: M,
next: F,
) -> Either<Self::Future, X> ⓘ
fn on_request<F, X>( &self, request: Request, meta: M, next: F, ) -> Either<Self::Future, X> ⓘ
Method invoked on each request. Allows you to either respond directly (without executing RPC call) or do any additional work before and/or after processing the request.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.