1use serde::{Deserialize, Serialize};
7
8macro_rules! opaque_id {
9 ($(#[$m:meta])* $name:ident) => {
10 $(#[$m])*
11 #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
12 #[serde(transparent)]
13 pub struct $name(pub String);
14
15 impl $name {
16 pub fn new(value: impl Into<String>) -> Self {
18 Self(value.into())
19 }
20
21 pub fn as_str(&self) -> &str {
23 &self.0
24 }
25 }
26
27 impl std::fmt::Display for $name {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 f.write_str(&self.0)
30 }
31 }
32 };
33}
34
35opaque_id! {
36 SessionId
38}
39
40opaque_id! {
41 AnnotationId
43}