Skip to main content

IRequest

Trait IRequest 

Source
pub trait IRequest<TResponse>: Send + 'static
where TResponse: Send + 'static,
{ }
Expand description

Marker trait for a request (command or query) carrying a structured response TResponse.

The HTTP adapter serializes TResponse as JSON, so it must implement serde::Serialize — unless it is crate::action::Response, the response-control type used for file downloads and other responses that own their status, headers and body. That is why this trait itself only requires Send: the Serialize bound is enforced where the value is actually serialized.

  • TResponse: Serialize → framework writes JSON and sets status 200
  • TResponse = () → framework writes no body and sets status 204
  • TResponse = Response → the handler builds the whole response
ⓘ
impl IRequest<UserModel> for GetUserRequest {}
impl IRequest<()> for DeleteUserRequest {}
impl IRequest<Response> for DownloadFileRequest {}

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§