1use smpte_types::Auid;
2
3#[derive(Debug, Clone)]
6pub struct ClassDefinition {
7 pub identification: Auid,
8 pub symbol: String,
9 pub namespace: String,
10 pub parent_class: Option<Auid>,
11 pub is_concrete: bool,
12}
13
14#[derive(Debug, Clone)]
17pub struct PropertyDefinition {
18 pub identification: Auid,
19 pub symbol: String,
20 pub namespace: String,
21 pub member_of: Auid,
22 pub property_type: Auid,
23 pub is_optional: bool,
24 pub is_unique_identifier: bool,
25 pub local_identification: u16,
26}
27
28#[derive(Debug, Clone)]
31pub struct CharacterTypeDef {
32 pub identification: Auid,
33 pub symbol: String,
34 pub namespace: String,
35}
36#[derive(Debug, Clone)]
37pub struct EnumerationElement {
38 pub name: String,
39 pub value: i64,
40}
41#[derive(Debug, Clone)]
42pub struct EnumerationTypeDef {
43 pub identification: Auid,
44 pub symbol: String,
45 pub namespace: String,
46 pub element_type: Auid,
47 pub elements: Vec<EnumerationElement>,
48}
49#[derive(Debug, Clone)]
50pub struct ExtEnumTypeDef {
51 pub identification: Auid,
52 pub symbol: String,
53 pub namespace: String,
54 pub elements: Vec<EnumerationElement>,
55}
56#[derive(Debug, Clone)]
57pub struct FixedArrayTypeDef {
58 pub identification: Auid,
59 pub symbol: String,
60 pub namespace: String,
61 pub element_type: Auid,
62 pub element_count: u32,
63}
64#[derive(Debug, Clone)]
65pub struct FloatTypeDef {
66 pub identification: Auid,
67 pub symbol: String,
68 pub namespace: String,
69 pub size: u8,
70}
71#[derive(Debug, Clone)]
72pub struct IndirectTypeDef {
73 pub identification: Auid,
74 pub symbol: String,
75 pub namespace: String,
76}
77#[derive(Debug, Clone)]
78pub struct IntegerTypeDef {
79 pub identification: Auid,
80 pub symbol: String,
81 pub namespace: String,
82 pub size: u8,
83 pub is_signed: bool,
84}
85#[derive(Debug, Clone)]
86pub struct LensSerialFloatTypeDef {
87 pub identification: Auid,
88 pub symbol: String,
89 pub namespace: String,
90}
91#[derive(Debug, Clone)]
92pub struct OpaqueTypeDef {
93 pub identification: Auid,
94 pub symbol: String,
95 pub namespace: String,
96}
97#[derive(Debug, Clone)]
98pub struct RecordMember {
99 pub name: String,
100 pub field_type: Auid,
101}
102#[derive(Debug, Clone)]
103pub struct RecordTypeDef {
104 pub identification: Auid,
105 pub symbol: String,
106 pub namespace: String,
107 pub members: Vec<RecordMember>,
108}
109#[derive(Debug, Clone)]
110pub struct RenameTypeDef {
111 pub identification: Auid,
112 pub symbol: String,
113 pub namespace: String,
114 pub renamed_type: Auid,
115}
116#[derive(Debug, Clone)]
117pub struct SetTypeDef {
118 pub identification: Auid,
119 pub symbol: String,
120 pub namespace: String,
121 pub element_type: Auid,
122}
123#[derive(Debug, Clone)]
124pub struct StreamTypeDef {
125 pub identification: Auid,
126 pub symbol: String,
127 pub namespace: String,
128}
129#[derive(Debug, Clone)]
130pub struct StringTypeDef {
131 pub identification: Auid,
132 pub symbol: String,
133 pub namespace: String,
134 pub element_type: Auid,
135}
136#[derive(Debug, Clone)]
137pub struct StrongReferenceTypeDef {
138 pub identification: Auid,
139 pub symbol: String,
140 pub namespace: String,
141 pub referenced_type: Auid,
142}
143#[derive(Debug, Clone)]
144pub struct VariableArrayTypeDef {
145 pub identification: Auid,
146 pub symbol: String,
147 pub namespace: String,
148 pub element_type: Auid,
149}
150#[derive(Debug, Clone)]
151pub struct WeakReferenceTypeDef {
152 pub identification: Auid,
153 pub symbol: String,
154 pub namespace: String,
155 pub referenced_type: Auid,
156 pub target_set: Vec<Auid>,
157}
158
159#[derive(Debug, Clone)]
161pub enum TypeDefinition {
162 Character(CharacterTypeDef),
163 Enumeration(EnumerationTypeDef),
164 ExtendibleEnumeration(ExtEnumTypeDef),
165 FixedArray(FixedArrayTypeDef),
166 Float(FloatTypeDef),
167 Indirect(IndirectTypeDef),
168 Integer(IntegerTypeDef),
169 LensSerialFloat(LensSerialFloatTypeDef),
170 Opaque(OpaqueTypeDef),
171 Record(RecordTypeDef),
172 Rename(RenameTypeDef),
173 Set(SetTypeDef),
174 Stream(StreamTypeDef),
175 String(StringTypeDef),
176 StrongReference(StrongReferenceTypeDef),
177 VariableArray(VariableArrayTypeDef),
178 WeakReference(WeakReferenceTypeDef),
179}
180
181#[derive(Debug, Clone)]
184pub enum Definition {
185 Class(ClassDefinition),
186 Property(PropertyDefinition),
187 Type(TypeDefinition),
188}
189
190impl Definition {
191 pub fn identification(&self) -> &Auid {
192 match self {
193 Definition::Class(d) => &d.identification,
194 Definition::Property(d) => &d.identification,
195 Definition::Type(td) => td.identification(),
196 }
197 }
198
199 pub fn symbol(&self) -> &str {
200 match self {
201 Definition::Class(d) => &d.symbol,
202 Definition::Property(d) => &d.symbol,
203 Definition::Type(td) => td.symbol(),
204 }
205 }
206}
207
208impl TypeDefinition {
209 pub fn identification(&self) -> &Auid {
210 match self {
211 TypeDefinition::Character(d) => &d.identification,
212 TypeDefinition::Enumeration(d) => &d.identification,
213 TypeDefinition::ExtendibleEnumeration(d) => &d.identification,
214 TypeDefinition::FixedArray(d) => &d.identification,
215 TypeDefinition::Float(d) => &d.identification,
216 TypeDefinition::Indirect(d) => &d.identification,
217 TypeDefinition::Integer(d) => &d.identification,
218 TypeDefinition::LensSerialFloat(d) => &d.identification,
219 TypeDefinition::Opaque(d) => &d.identification,
220 TypeDefinition::Record(d) => &d.identification,
221 TypeDefinition::Rename(d) => &d.identification,
222 TypeDefinition::Set(d) => &d.identification,
223 TypeDefinition::Stream(d) => &d.identification,
224 TypeDefinition::String(d) => &d.identification,
225 TypeDefinition::StrongReference(d) => &d.identification,
226 TypeDefinition::VariableArray(d) => &d.identification,
227 TypeDefinition::WeakReference(d) => &d.identification,
228 }
229 }
230
231 pub fn symbol(&self) -> &str {
232 match self {
233 TypeDefinition::Character(d) => &d.symbol,
234 TypeDefinition::Enumeration(d) => &d.symbol,
235 TypeDefinition::ExtendibleEnumeration(d) => &d.symbol,
236 TypeDefinition::FixedArray(d) => &d.symbol,
237 TypeDefinition::Float(d) => &d.symbol,
238 TypeDefinition::Indirect(d) => &d.symbol,
239 TypeDefinition::Integer(d) => &d.symbol,
240 TypeDefinition::LensSerialFloat(d) => &d.symbol,
241 TypeDefinition::Opaque(d) => &d.symbol,
242 TypeDefinition::Record(d) => &d.symbol,
243 TypeDefinition::Rename(d) => &d.symbol,
244 TypeDefinition::Set(d) => &d.symbol,
245 TypeDefinition::Stream(d) => &d.symbol,
246 TypeDefinition::String(d) => &d.symbol,
247 TypeDefinition::StrongReference(d) => &d.symbol,
248 TypeDefinition::VariableArray(d) => &d.symbol,
249 TypeDefinition::WeakReference(d) => &d.symbol,
250 }
251 }
252
253 pub fn namespace(&self) -> &str {
254 match self {
255 TypeDefinition::Character(d) => &d.namespace,
256 TypeDefinition::Enumeration(d) => &d.namespace,
257 TypeDefinition::ExtendibleEnumeration(d) => &d.namespace,
258 TypeDefinition::FixedArray(d) => &d.namespace,
259 TypeDefinition::Float(d) => &d.namespace,
260 TypeDefinition::Indirect(d) => &d.namespace,
261 TypeDefinition::Integer(d) => &d.namespace,
262 TypeDefinition::LensSerialFloat(d) => &d.namespace,
263 TypeDefinition::Opaque(d) => &d.namespace,
264 TypeDefinition::Record(d) => &d.namespace,
265 TypeDefinition::Rename(d) => &d.namespace,
266 TypeDefinition::Set(d) => &d.namespace,
267 TypeDefinition::Stream(d) => &d.namespace,
268 TypeDefinition::String(d) => &d.namespace,
269 TypeDefinition::StrongReference(d) => &d.namespace,
270 TypeDefinition::VariableArray(d) => &d.namespace,
271 TypeDefinition::WeakReference(d) => &d.namespace,
272 }
273 }
274}