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::route::scan::ResponseData, the raw-response envelope used for file downloads and other responses that control their own 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 = ResponseData → the handler builds the whole response
ⓘ
impl IRequest<UserModel> for GetUserRequest {}
impl IRequest<()> for DeleteUserRequest {}
impl IRequest<ResponseData> for DownloadFileRequest {}

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§