summaryrefslogtreecommitdiff
path: root/src/message/body.rs
blob: a415f854d426f852e512ba559e4246072bf7bec3 (plain)
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
use std::fmt;

use crate::nfc;

#[derive(
    Clone, Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, sqlx::Type,
)]
#[serde(transparent)]
#[sqlx(transparent)]
pub struct Body(nfc::String);

impl fmt::Display for Body {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let Self(body) = self;
        body.fmt(f)
    }
}

impl From<String> for Body {
    fn from(body: String) -> Self {
        Self(body.into())
    }
}

impl From<Body> for String {
    fn from(body: Body) -> Self {
        let Body(body) = body;
        body.into()
    }
}