1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
5#[serde(transparent)]
6pub struct SurfaceId(pub String);
7
8impl SurfaceId {
9 pub fn new(id: impl Into<String>) -> Self {
10 Self(id.into())
11 }
12
13 pub fn as_str(&self) -> &str {
14 &self.0
15 }
16}
17
18impl From<&str> for SurfaceId {
19 fn from(s: &str) -> Self {
20 Self(s.to_owned())
21 }
22}
23
24impl From<String> for SurfaceId {
25 fn from(s: String) -> Self {
26 Self(s)
27 }
28}
29
30#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
32#[serde(transparent)]
33pub struct ComponentId(pub String);
34
35impl ComponentId {
36 pub fn new(id: impl Into<String>) -> Self {
37 Self(id.into())
38 }
39
40 pub fn as_str(&self) -> &str {
41 &self.0
42 }
43}
44
45impl From<&str> for ComponentId {
46 fn from(s: &str) -> Self {
47 Self(s.to_owned())
48 }
49}
50
51impl From<String> for ComponentId {
52 fn from(s: String) -> Self {
53 Self(s)
54 }
55}
56
57#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
59#[serde(transparent)]
60pub struct CatalogId(pub String);
61
62impl CatalogId {
63 pub fn new(id: impl Into<String>) -> Self {
64 Self(id.into())
65 }
66
67 pub fn as_str(&self) -> &str {
68 &self.0
69 }
70}
71
72impl From<&str> for CatalogId {
73 fn from(s: &str) -> Self {
74 Self(s.to_owned())
75 }
76}
77
78impl From<String> for CatalogId {
79 fn from(s: String) -> Self {
80 Self(s)
81 }
82}
83
84#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
86pub enum SpecVersion {
87 V0_9,
88 V0_9_1,
89 V1_0,
90}
91
92impl SpecVersion {
93 pub fn parse(version: &str) -> Option<Self> {
97 match version {
98 "v0.9" => Some(Self::V0_9),
99 "v0.9.1" => Some(Self::V0_9_1),
100 "v1.0" => Some(Self::V1_0),
101 _ => None,
102 }
103 }
104}
105
106impl std::fmt::Display for SpecVersion {
107 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
108 match self {
109 SpecVersion::V0_9 => write!(f, "v0.9"),
110 SpecVersion::V0_9_1 => write!(f, "v0.9.1"),
111 SpecVersion::V1_0 => write!(f, "v1.0"),
112 }
113 }
114}