1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/// 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;
/// }
/// ```
#[cfg(feature = "serde")]
pub trait Request: serde::Deserialize<'static> + Send + Sync {
    /// Request response type.
    type Response: serde::Serialize + Send + Sync;
}

#[cfg(not(feature = "serde"))]
pub trait Request {
    type Response;
}