pub trait IRequestHandler<T, R>: Send + Sync{
// Required method
fn handle<'life0, 'async_trait>(
&'life0 mut self,
req: T,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}Expand description
Handles a single IRequest<R>, producing its associated response R.
Authentication claims are NOT passed as a method parameter — this trait stays
free of auth concerns. Instead, requests that need claims implement the
inherent set_claims method (see IClaimsCarrier); the dispatcher injects
claims into the request before calling handle.
Register via #[handler] proc macro for compile-time collection,
or use register_handlers! for manual DI registration.
handle(&mut self, ...) enables the EFCore-style owned-DbContext pattern:
handlers declare a bare ctx: DbContext field, resolved per-request via
IServiceResolver::get_owned, and mutate it directly without Arc<Mutex>.
#[async_trait]
impl IRequestHandler<GetUserRequest, UserModel> for GetUserHandler {
async fn handle(&mut self, req: GetUserRequest) -> Result<UserModel> { ... }
}Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".