1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Serialize, Deserialize)]
4pub struct Id(String);
6
7impl From<String> for Id {
8 fn from(s: String) -> Self {
9 Self(s)
10 }
11}
12
13impl From<&String> for Id {
14 fn from(s: &String) -> Self {
15 Self(s.clone())
16 }
17}
18
19impl From<&str> for Id {
20 fn from(s: &str) -> Self {
21 Self(s.to_string())
22 }
23}
24
25impl From<std::borrow::Cow<'_, str>> for Id {
26 fn from(s: std::borrow::Cow<'_, str>) -> Self {
27 Self(s.to_string())
28 }
29}
30
31impl AsRef<str> for Id {
32 fn as_ref(&self) -> &str {
33 &self.0
34 }
35}
36
37impl std::fmt::Display for Id {
38 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39 write!(f, "{}", self.0)
40 }
41}