Slide 32
Slide 32 text
API-layer | De/Serialization
@algo_luca
lpalmieri.com
:[derive(Serialize, Deserialize, Clone, Debug)]
:[serde(rename_all = "camelCase")]
pub struct Comment {
pub id: u64,
pub created_at: DateTime,
pub updated_at: DateTime,
pub body: String,
pub author: Author,
}
impl From for Comment {
fn from(c: domain::Comment) :> Self {
Self {
id: c.id,
body: c.body,
created_at: c.created_at,
updated_at: c.updated_at,
author: c.author.into(),
}
}
}