Trait ddd_rs::presentation::Request
source · pub trait Request: Deserialize<'static> + Send + Sync {
type Response: Serialize + Send + Sync;
}Expand description
Trait for representing a Request.
Requests are usually commands or queries, and their sole requirement is to have an associated Response type.
- Queries: Return a result and do not change the observable state of the system (are free of side effects).
- Commands: Change the state of a system but do not return a value.
Examples
use ddd_rs::presentation::Request;
#[derive(serde::Deserialize)]
struct MyRequest {
a: bool,
b: i32,
c: String,
}
#[derive(serde::Serialize)]
struct MyResponse {
foo: String,
bar: i32,
}
impl Request for MyRequest {
type Response = MyResponse;
}