pub trait IRequestHandler<T, R>: Send + Sync{
// Required method
fn handle<'life0, 'async_trait>(
&'life0 self,
req: T,
) -> Pin<Box<dyn Future<Output = Result<R>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn handle_with_claims<'life0, 'life1, 'async_trait>(
&'life0 self,
req: T,
claims: Option<&'life1 dyn IClaims>,
) -> Pin<Box<dyn Future<Output = Result<R>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Handles a single IRequest<R>, producing its associated response R.
Register via #[handler] proc macro for compile-time collection,
or use register_handlers! for manual DI registration.
ⓘ
#[async_trait]
impl IRequestHandler<GetUserRequest, UserModel> for GetUserHandler {
async fn handle(&self, req: GetUserRequest) -> Result<UserModel> { ... }
}Required Methods§
Provided Methods§
Sourcefn handle_with_claims<'life0, 'life1, 'async_trait>(
&'life0 self,
req: T,
claims: Option<&'life1 dyn IClaims>,
) -> Pin<Box<dyn Future<Output = Result<R>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_with_claims<'life0, 'life1, 'async_trait>(
&'life0 self,
req: T,
claims: Option<&'life1 dyn IClaims>,
) -> Pin<Box<dyn Future<Output = Result<R>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Handle the request with optional authentication claims.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".