Skip to main content

IRequestHandler

Trait IRequestHandler 

Source
pub trait IRequestHandler<T, R>: Send + Sync
where T: IRequest<R> + Send + 'static, R: Serialize + Send + 'static,
{ // 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§

Source

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,

Handle the request without claims.

Provided Methods§

Source

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".

Implementors§