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
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Appellation<T = String> {
pub id: T,
pub key: T, pub label: T,
}
impl<T> Appellation<T> {
pub fn new(id: T, key: T, label: T) -> Self {
Self { id, key, label }
}
}
impl<T: Serialize> std::fmt::Debug for Appellation<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", serde_json::to_string_pretty(&self).unwrap())
}
}
impl<T: Serialize> std::fmt::Display for Appellation<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", serde_json::to_string(&self).unwrap())
}
}