framework_cqrs_lib/cqrs/models/views/
entities.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::collections::HashMap;

use serde::{Deserialize, Serialize};
use utoipa::ToSchema;

#[derive(Serialize, Deserialize, Clone, ToSchema, Debug)]
pub struct EntityView<T>
where
    T: Serialize + Clone,
{
    pub r#type: String,
    pub id: String,
    pub attributes: T,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub links: Option<LinksEntityView>,
}

#[derive(Serialize, Deserialize, Clone, ToSchema, Debug)]
pub struct LinksEntityView {
    #[serde(flatten)]
    pub links: HashMap<String, String>,
}