Skip to main content

Module handler

Module handler 

Source
Expand description

Handler traits: IRequestHandler and IEventHandler.

§IRequestHandler<T, R>

Dual-type-parameter handler: T is the request type, R is the response type. The constraint T: IRequest<R> ensures type safety between request and response.

#[async_trait]
impl IRequestHandler<GetUserRequest, UserModel> for GetUserHandler {
    async fn handle(&self, req: GetUserRequest) -> Result<UserModel> { ... }
}

Traits§

IEventHandler
Handles a single IEventRequest, performing side effects.
IHostedService
Background service that is started when the host starts and stopped when the host performs a graceful shutdown.
IRequestHandler
Handles a single IRequest<R>, producing its associated response R.