1#[allow(non_snake_case)]
4pub mod DDS {
5 #[allow(non_snake_case)]
6 pub mod XTypes {
7 pub type EquivalenceKind = u8;
8 pub const EK_MINIMAL: u8 = 241;
9 pub const EK_COMPLETE: u8 = 242;
10 pub const EK_BOTH: u8 = 243;
11 pub type TypeKind = u8;
12 pub const TK_NONE: u8 = 0;
13 pub const TK_BOOLEAN: u8 = 1;
14 pub const TK_BYTE: u8 = 2;
15 pub const TK_INT16: u8 = 3;
16 pub const TK_INT32: u8 = 4;
17 pub const TK_INT64: u8 = 5;
18 pub const TK_UINT16: u8 = 6;
19 pub const TK_UINT32: u8 = 7;
20 pub const TK_UINT64: u8 = 8;
21 pub const TK_FLOAT32: u8 = 9;
22 pub const TK_FLOAT64: u8 = 10;
23 pub const TK_FLOAT128: u8 = 11;
24 pub const TK_CHAR8: u8 = 16;
25 pub const TK_CHAR16: u8 = 17;
26 pub const TK_STRING8: u8 = 32;
27 pub const TK_STRING16: u8 = 33;
28 pub const TK_ALIAS: u8 = 48;
29 pub const TK_ENUM: u8 = 64;
30 pub const TK_BITMASK: u8 = 65;
31 pub const TK_ANNOTATION: u8 = 80;
32 pub const TK_STRUCTURE: u8 = 81;
33 pub const TK_UNION: u8 = 82;
34 pub const TK_BITSET: u8 = 83;
35 pub const TK_SEQUENCE: u8 = 96;
36 pub const TK_ARRAY: u8 = 97;
37 pub const TK_MAP: u8 = 98;
38 pub type TypeIdentiferKind = u8;
39 pub const TI_STRING8_SMALL: u8 = 112;
40 pub const TI_STRING8_LARGE: u8 = 113;
41 pub const TI_STRING16_SMALL: u8 = 114;
42 pub const TI_STRING16_LARGE: u8 = 115;
43 pub const TI_PLAIN_SEQUENCE_SMALL: u8 = 128;
44 pub const TI_PLAIN_SEQUENCE_LARGE: u8 = 129;
45 pub const TI_PLAIN_ARRAY_SMALL: u8 = 144;
46 pub const TI_PLAIN_ARRAY_LARGE: u8 = 145;
47 pub const TI_PLAIN_MAP_SMALL: u8 = 160;
48 pub const TI_PLAIN_MAP_LARGE: u8 = 161;
49 pub const TI_STRONGLY_CONNECTED_COMPONENT: u8 = 176;
50 pub const MEMBER_NAME_MAX_LENGTH: i32 = 256;
51 pub type MemberName = String;
52 pub const TYPE_NAME_MAX_LENGTH: i32 = 256;
53 pub type QualifiedTypeName = String;
54 pub type PrimitiveTypeId = u8;
55 pub type EquivalenceHash = [u8; 14];
56 pub type NameHash = [u8; 4];
57 pub type LBound = u32;
58 pub type LBoundSeq = Vec<LBound>;
59 pub const INVALID_LBOUND: LBound = 0;
60 pub type SBound = u8;
61 pub type SBoundSeq = Vec<SBound>;
62 pub const INVALID_SBOUND: SBound = 0;
63 pub struct TypeObjectHashId {
64 tag: u8,
65 data: TypeObjectHashIdData,
66 }
67 union TypeObjectHashIdData {
68 hash: core::mem::ManuallyDrop<EquivalenceHash>,
69 }
70 impl Drop for TypeObjectHashId {
71 #[allow(unreachable_patterns)]
72 fn drop(&mut self) {
73 match self.tag {
74 EK_COMPLETE | EK_MINIMAL => unsafe {
75 core::mem::ManuallyDrop::drop(&mut self.data.hash);
76 },
77 _ => {}
78 }
79 }
80 }
81 impl Clone for TypeObjectHashId {
82 #[allow(clippy::clone_on_copy)]
83 #[allow(unreachable_patterns)]
84 fn clone(&self) -> Self {
85 match self.tag {
86 EK_COMPLETE | EK_MINIMAL => Self::new_hash(self.as_hash().clone()),
87 _ => unreachable!(),
88 }
89 }
90 }
91 impl core::fmt::Debug for TypeObjectHashId {
92 #[allow(unreachable_patterns)]
93 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
94 let mut d = f.debug_struct("TypeObjectHashId");
95 d.field("tag", &self.tag);
96 match self.tag {
97 EK_COMPLETE | EK_MINIMAL => {
98 d.field("hash", self.as_hash());
99 }
100 _ => {}
101 }
102 d.finish()
103 }
104 }
105 impl PartialEq for TypeObjectHashId {
106 #[allow(unreachable_patterns)]
107 fn eq(&self, other: &Self) -> bool {
108 if self.tag != other.tag {
109 return false;
110 }
111 match self.tag {
112 EK_COMPLETE | EK_MINIMAL => self.as_hash() == other.as_hash(),
113 _ => false,
114 }
115 }
116 }
117 impl TypeObjectHashId {
118 pub fn new_hash(value: EquivalenceHash) -> Self {
119 Self {
120 tag: EK_COMPLETE,
121 data: TypeObjectHashIdData {
122 hash: core::mem::ManuallyDrop::new(value),
123 },
124 }
125 }
126 pub fn is_hash(&self) -> bool {
127 matches!(self.tag, EK_COMPLETE | EK_MINIMAL)
128 }
129 #[allow(clippy::borrowed_box)]
130 pub fn as_hash(&self) -> &EquivalenceHash {
131 debug_assert!(self.is_hash());
132 unsafe { &self.data.hash }
133 }
134 #[allow(clippy::borrowed_box)]
135 pub fn as_hash_mut(&mut self) -> &mut EquivalenceHash {
136 debug_assert!(self.is_hash());
137 unsafe { &mut self.data.hash }
138 }
139 pub fn into_hash(self) -> EquivalenceHash {
140 debug_assert!(self.is_hash());
141 unsafe {
142 let mut forget = core::mem::ManuallyDrop::new(self);
143 core::mem::ManuallyDrop::take(&mut forget.data.hash)
144 }
145 }
146 pub fn tag(&self) -> &u8 {
147 &self.tag
148 }
149 }
150 impl Default for TypeObjectHashId {
151 fn default() -> Self {
152 Self {
153 tag: EK_COMPLETE,
154 data: TypeObjectHashIdData {
155 hash: core::mem::ManuallyDrop::new(EquivalenceHash::default()),
156 },
157 }
158 }
159 }
160 #[derive(::serde::Serialize)]
161 struct TypeObjectHashIdSerdeRef<'__a> {
162 tag: &'__a str,
163 data: TypeObjectHashIdSerdeRefData<'__a>,
164 }
165 #[allow(clippy::borrowed_box)]
166 #[derive(::serde::Serialize)]
167 #[serde(untagged)]
168 enum TypeObjectHashIdSerdeRefData<'__a> {
169 Case0(&'__a EquivalenceHash),
170 }
171 impl serde::Serialize for TypeObjectHashId {
172 #[allow(unreachable_patterns)]
173 fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
174 where
175 __S: serde::Serializer,
176 {
177 let helper = match self.tag {
178 EK_COMPLETE | EK_MINIMAL => {
179 let tag = match self.tag {
180 EK_COMPLETE => "EK_COMPLETE",
181 _ => "EK_MINIMAL",
182 };
183 TypeObjectHashIdSerdeRef {
184 tag,
185 data: TypeObjectHashIdSerdeRefData::Case0(self.as_hash()),
186 }
187 }
188 _ => unreachable!(),
189 };
190 helper.serialize(__serializer)
191 }
192 }
193 #[derive(::serde::Deserialize)]
194 struct TypeObjectHashIdSerdeOwned {
195 tag: String,
196 data: ::serde_json::Value,
197 }
198 impl<'de> serde::Deserialize<'de> for TypeObjectHashId {
199 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
200 where
201 D: serde::Deserializer<'de>,
202 {
203 let helper = TypeObjectHashIdSerdeOwned::deserialize(deserializer)?;
204 match helper.tag.as_str() {
205 "EK_COMPLETE" => {
206 let value = ::serde_json::from_value::<
207 EquivalenceHash,
208 >(helper.data)
209 .map_err(|err| serde::de::Error::custom(
210 format!(
211 "union TypeObjectHashId payload decode failed for tag `EK_COMPLETE`: {err}"
212 ),
213 ))?;
214 Ok(Self {
215 tag: EK_COMPLETE,
216 data: TypeObjectHashIdData {
217 hash: core::mem::ManuallyDrop::new(value),
218 },
219 })
220 }
221 "EK_MINIMAL" => {
222 let value = ::serde_json::from_value::<
223 EquivalenceHash,
224 >(helper.data)
225 .map_err(|err| serde::de::Error::custom(
226 format!(
227 "union TypeObjectHashId payload decode failed for tag `EK_MINIMAL`: {err}"
228 ),
229 ))?;
230 Ok(Self {
231 tag: EK_MINIMAL,
232 data: TypeObjectHashIdData {
233 hash: core::mem::ManuallyDrop::new(value),
234 },
235 })
236 }
237 _ => Err(serde::de::Error::custom(format!(
238 "union TypeObjectHashId tag/data mismatch for tag `{}`",
239 helper.tag
240 ))),
241 }
242 }
243 }
244 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
245 pub struct MemberFlag {
246 pub value: u32,
247 }
248 impl MemberFlag {
249 pub const TRY_CONSTRUCT1: u32 = 1u32 << 0;
250 pub const TRY_CONSTRUCT2: u32 = 1u32 << 1;
251 pub const IS_EXTERNAL: u32 = 1u32 << 2;
252 pub const IS_OPTIONAL: u32 = 1u32 << 3;
253 pub const IS_MUST_UNDERSTAND: u32 = 1u32 << 4;
254 pub const IS_KEY: u32 = 1u32 << 5;
255 pub const IS_DEFAULT: u32 = 1u32 << 6;
256 }
257 pub type CollectionElementFlag = MemberFlag;
258 pub type StructMemberFlag = MemberFlag;
259 pub type UnionMemberFlag = MemberFlag;
260 pub type UnionDiscriminatorFlag = MemberFlag;
261 pub type EnumeratedLiteralFlag = MemberFlag;
262 pub type AnnotationParameterFlag = MemberFlag;
263 pub type AliasMemberFlag = MemberFlag;
264 pub type BitflagFlag = MemberFlag;
265 pub type BitsetMemberFlag = MemberFlag;
266 #[allow(non_upper_case_globals)]
267 pub const MemberFlagMinimalMask: u16 = 63;
268 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
269 pub struct TypeFlag {
270 pub value: u32,
271 }
272 impl TypeFlag {
273 pub const IS_FINAL: u32 = 1u32 << 0;
274 pub const IS_APPENDABLE: u32 = 1u32 << 1;
275 pub const IS_MUTABLE: u32 = 1u32 << 2;
276 pub const IS_NESTED: u32 = 1u32 << 3;
277 pub const IS_AUTOID_HASH: u32 = 1u32 << 4;
278 }
279 pub type StructTypeFlag = TypeFlag;
280 pub type UnionTypeFlag = TypeFlag;
281 pub type CollectionTypeFlag = TypeFlag;
282 pub type AnnotationTypeFlag = TypeFlag;
283 pub type AliasTypeFlag = TypeFlag;
284 pub type EnumTypeFlag = TypeFlag;
285 pub type BitmaskTypeFlag = TypeFlag;
286 pub type BitsetTypeFlag = TypeFlag;
287 #[allow(non_upper_case_globals)]
288 pub const TypeFlagMinimalMask: u16 = 7;
289 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
290 pub struct StringSTypeDefn {
291 pub bound: SBound,
292 }
293 impl StringSTypeDefn {}
294 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
295 pub struct StringLTypeDefn {
296 pub bound: LBound,
297 }
298 impl StringLTypeDefn {}
299 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
300 pub struct PlainCollectionHeader {
301 pub equiv_kind: EquivalenceKind,
302 pub element_flags: CollectionElementFlag,
303 }
304 impl PlainCollectionHeader {}
305 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
306 pub struct PlainSequenceSElemDefn {
307 pub header: PlainCollectionHeader,
308 pub bound: SBound,
309 pub element_identifier: Box<TypeIdentifier>,
310 }
311 impl PlainSequenceSElemDefn {}
312 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
313 pub struct PlainSequenceLElemDefn {
314 pub header: PlainCollectionHeader,
315 pub bound: LBound,
316 pub element_identifier: Box<TypeIdentifier>,
317 }
318 impl PlainSequenceLElemDefn {}
319 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
320 pub struct PlainArraySElemDefn {
321 pub header: PlainCollectionHeader,
322 pub array_bound_seq: SBoundSeq,
323 pub element_identifier: Box<TypeIdentifier>,
324 }
325 impl PlainArraySElemDefn {}
326 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
327 pub struct PlainArrayLElemDefn {
328 pub header: PlainCollectionHeader,
329 pub array_bound_seq: LBoundSeq,
330 pub element_identifier: Box<TypeIdentifier>,
331 }
332 impl PlainArrayLElemDefn {}
333 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
334 pub struct PlainMapSTypeDefn {
335 pub header: PlainCollectionHeader,
336 pub bound: SBound,
337 pub element_identifier: Box<TypeIdentifier>,
338 pub key_flags: CollectionElementFlag,
339 pub key_identifier: Box<TypeIdentifier>,
340 }
341 impl PlainMapSTypeDefn {}
342 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
343 pub struct PlainMapLTypeDefn {
344 pub header: PlainCollectionHeader,
345 pub bound: LBound,
346 pub element_identifier: Box<TypeIdentifier>,
347 pub key_flags: CollectionElementFlag,
348 pub key_identifier: Box<TypeIdentifier>,
349 }
350 impl PlainMapLTypeDefn {}
351 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
352 pub struct StronglyConnectedComponentId {
353 pub sc_component_id: TypeObjectHashId,
354 pub scc_length: i32,
355 pub scc_index: i32,
356 }
357 impl StronglyConnectedComponentId {}
358 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
359 pub struct ExtendedTypeDefn {}
360 impl ExtendedTypeDefn {}
361 pub struct TypeIdentifier {
362 tag: u8,
363 data: TypeIdentifierData,
364 }
365 union TypeIdentifierData {
366 string_sdefn: core::mem::ManuallyDrop<StringSTypeDefn>,
367 string_ldefn: core::mem::ManuallyDrop<StringLTypeDefn>,
368 seq_sdefn: core::mem::ManuallyDrop<Box<PlainSequenceSElemDefn>>,
369 seq_ldefn: core::mem::ManuallyDrop<Box<PlainSequenceLElemDefn>>,
370 array_sdefn: core::mem::ManuallyDrop<Box<PlainArraySElemDefn>>,
371 array_ldefn: core::mem::ManuallyDrop<Box<PlainArrayLElemDefn>>,
372 map_sdefn: core::mem::ManuallyDrop<Box<PlainMapSTypeDefn>>,
373 map_ldefn: core::mem::ManuallyDrop<Box<PlainMapLTypeDefn>>,
374 sc_component_id: core::mem::ManuallyDrop<StronglyConnectedComponentId>,
375 equivalence_hash: core::mem::ManuallyDrop<EquivalenceHash>,
376 extended_defn: core::mem::ManuallyDrop<ExtendedTypeDefn>,
377 }
378 impl Drop for TypeIdentifier {
379 #[allow(unreachable_patterns)]
380 fn drop(&mut self) {
381 if matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL) {
382 unsafe {
383 core::mem::ManuallyDrop::drop(&mut self.data.string_sdefn);
384 }
385 } else if matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE) {
386 unsafe {
387 core::mem::ManuallyDrop::drop(&mut self.data.string_ldefn);
388 }
389 } else if matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL) {
390 unsafe {
391 core::mem::ManuallyDrop::drop(&mut self.data.seq_sdefn);
392 }
393 } else if matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE) {
394 unsafe {
395 core::mem::ManuallyDrop::drop(&mut self.data.seq_ldefn);
396 }
397 } else if matches!(self.tag, TI_PLAIN_ARRAY_SMALL) {
398 unsafe {
399 core::mem::ManuallyDrop::drop(&mut self.data.array_sdefn);
400 }
401 } else if matches!(self.tag, TI_PLAIN_ARRAY_LARGE) {
402 unsafe {
403 core::mem::ManuallyDrop::drop(&mut self.data.array_ldefn);
404 }
405 } else if matches!(self.tag, TI_PLAIN_MAP_SMALL) {
406 unsafe {
407 core::mem::ManuallyDrop::drop(&mut self.data.map_sdefn);
408 }
409 } else if matches!(self.tag, TI_PLAIN_MAP_LARGE) {
410 unsafe {
411 core::mem::ManuallyDrop::drop(&mut self.data.map_ldefn);
412 }
413 } else if matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT) {
414 unsafe {
415 core::mem::ManuallyDrop::drop(&mut self.data.sc_component_id);
416 }
417 } else if matches!(self.tag, EK_COMPLETE | EK_MINIMAL) {
418 unsafe {
419 core::mem::ManuallyDrop::drop(&mut self.data.equivalence_hash);
420 }
421 } else {
422 unsafe {
423 core::mem::ManuallyDrop::drop(&mut self.data.extended_defn);
424 }
425 }
426 }
427 }
428 impl Clone for TypeIdentifier {
429 #[allow(clippy::clone_on_copy)]
430 #[allow(unreachable_patterns)]
431 fn clone(&self) -> Self {
432 if matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL) {
433 Self::new_string_sdefn(self.as_string_sdefn().clone())
434 } else if matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE) {
435 Self::new_string_ldefn(self.as_string_ldefn().clone())
436 } else if matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL) {
437 Self::new_seq_sdefn(self.as_seq_sdefn().clone())
438 } else if matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE) {
439 Self::new_seq_ldefn(self.as_seq_ldefn().clone())
440 } else if matches!(self.tag, TI_PLAIN_ARRAY_SMALL) {
441 Self::new_array_sdefn(self.as_array_sdefn().clone())
442 } else if matches!(self.tag, TI_PLAIN_ARRAY_LARGE) {
443 Self::new_array_ldefn(self.as_array_ldefn().clone())
444 } else if matches!(self.tag, TI_PLAIN_MAP_SMALL) {
445 Self::new_map_sdefn(self.as_map_sdefn().clone())
446 } else if matches!(self.tag, TI_PLAIN_MAP_LARGE) {
447 Self::new_map_ldefn(self.as_map_ldefn().clone())
448 } else if matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT) {
449 Self::new_sc_component_id(self.as_sc_component_id().clone())
450 } else if matches!(self.tag, EK_COMPLETE | EK_MINIMAL) {
451 Self::new_equivalence_hash(self.as_equivalence_hash().clone())
452 } else {
453 Self::new_extended_defn(self.as_extended_defn().clone())
454 }
455 }
456 }
457 impl core::fmt::Debug for TypeIdentifier {
458 #[allow(unreachable_patterns)]
459 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
460 let mut d = f.debug_struct("TypeIdentifier");
461 d.field("tag", &self.tag);
462 if matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL) {
463 d.field("string_sdefn", self.as_string_sdefn());
464 } else if matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE) {
465 d.field("string_ldefn", self.as_string_ldefn());
466 } else if matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL) {
467 d.field("seq_sdefn", self.as_seq_sdefn());
468 } else if matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE) {
469 d.field("seq_ldefn", self.as_seq_ldefn());
470 } else if matches!(self.tag, TI_PLAIN_ARRAY_SMALL) {
471 d.field("array_sdefn", self.as_array_sdefn());
472 } else if matches!(self.tag, TI_PLAIN_ARRAY_LARGE) {
473 d.field("array_ldefn", self.as_array_ldefn());
474 } else if matches!(self.tag, TI_PLAIN_MAP_SMALL) {
475 d.field("map_sdefn", self.as_map_sdefn());
476 } else if matches!(self.tag, TI_PLAIN_MAP_LARGE) {
477 d.field("map_ldefn", self.as_map_ldefn());
478 } else if matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT) {
479 d.field("sc_component_id", self.as_sc_component_id());
480 } else if matches!(self.tag, EK_COMPLETE | EK_MINIMAL) {
481 d.field("equivalence_hash", self.as_equivalence_hash());
482 } else {
483 d.field("extended_defn", self.as_extended_defn());
484 }
485 d.finish()
486 }
487 }
488 impl PartialEq for TypeIdentifier {
489 #[allow(unreachable_patterns)]
490 fn eq(&self, other: &Self) -> bool {
491 if self.tag != other.tag {
492 return false;
493 }
494 if matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL) {
495 self.as_string_sdefn() == other.as_string_sdefn()
496 } else if matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE) {
497 self.as_string_ldefn() == other.as_string_ldefn()
498 } else if matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL) {
499 self.as_seq_sdefn() == other.as_seq_sdefn()
500 } else if matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE) {
501 self.as_seq_ldefn() == other.as_seq_ldefn()
502 } else if matches!(self.tag, TI_PLAIN_ARRAY_SMALL) {
503 self.as_array_sdefn() == other.as_array_sdefn()
504 } else if matches!(self.tag, TI_PLAIN_ARRAY_LARGE) {
505 self.as_array_ldefn() == other.as_array_ldefn()
506 } else if matches!(self.tag, TI_PLAIN_MAP_SMALL) {
507 self.as_map_sdefn() == other.as_map_sdefn()
508 } else if matches!(self.tag, TI_PLAIN_MAP_LARGE) {
509 self.as_map_ldefn() == other.as_map_ldefn()
510 } else if matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT) {
511 self.as_sc_component_id() == other.as_sc_component_id()
512 } else if matches!(self.tag, EK_COMPLETE | EK_MINIMAL) {
513 self.as_equivalence_hash() == other.as_equivalence_hash()
514 } else {
515 self.as_extended_defn() == other.as_extended_defn()
516 }
517 }
518 }
519 impl TypeIdentifier {
520 pub fn new_string_sdefn(value: StringSTypeDefn) -> Self {
521 Self {
522 tag: TI_STRING8_SMALL,
523 data: TypeIdentifierData {
524 string_sdefn: core::mem::ManuallyDrop::new(value),
525 },
526 }
527 }
528 pub fn is_string_sdefn(&self) -> bool {
529 matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL)
530 }
531 #[allow(clippy::borrowed_box)]
532 pub fn as_string_sdefn(&self) -> &StringSTypeDefn {
533 debug_assert!(self.is_string_sdefn());
534 unsafe { &self.data.string_sdefn }
535 }
536 #[allow(clippy::borrowed_box)]
537 pub fn as_string_sdefn_mut(&mut self) -> &mut StringSTypeDefn {
538 debug_assert!(self.is_string_sdefn());
539 unsafe { &mut self.data.string_sdefn }
540 }
541 pub fn into_string_sdefn(self) -> StringSTypeDefn {
542 debug_assert!(self.is_string_sdefn());
543 unsafe {
544 let mut forget = core::mem::ManuallyDrop::new(self);
545 core::mem::ManuallyDrop::take(&mut forget.data.string_sdefn)
546 }
547 }
548 pub fn new_string_ldefn(value: StringLTypeDefn) -> Self {
549 Self {
550 tag: TI_STRING8_LARGE,
551 data: TypeIdentifierData {
552 string_ldefn: core::mem::ManuallyDrop::new(value),
553 },
554 }
555 }
556 pub fn is_string_ldefn(&self) -> bool {
557 matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE)
558 }
559 #[allow(clippy::borrowed_box)]
560 pub fn as_string_ldefn(&self) -> &StringLTypeDefn {
561 debug_assert!(self.is_string_ldefn());
562 unsafe { &self.data.string_ldefn }
563 }
564 #[allow(clippy::borrowed_box)]
565 pub fn as_string_ldefn_mut(&mut self) -> &mut StringLTypeDefn {
566 debug_assert!(self.is_string_ldefn());
567 unsafe { &mut self.data.string_ldefn }
568 }
569 pub fn into_string_ldefn(self) -> StringLTypeDefn {
570 debug_assert!(self.is_string_ldefn());
571 unsafe {
572 let mut forget = core::mem::ManuallyDrop::new(self);
573 core::mem::ManuallyDrop::take(&mut forget.data.string_ldefn)
574 }
575 }
576 pub fn new_seq_sdefn(value: Box<PlainSequenceSElemDefn>) -> Self {
577 Self {
578 tag: TI_PLAIN_SEQUENCE_SMALL,
579 data: TypeIdentifierData {
580 seq_sdefn: core::mem::ManuallyDrop::new(value),
581 },
582 }
583 }
584 pub fn is_seq_sdefn(&self) -> bool {
585 matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL)
586 }
587 #[allow(clippy::borrowed_box)]
588 pub fn as_seq_sdefn(&self) -> &Box<PlainSequenceSElemDefn> {
589 debug_assert!(self.is_seq_sdefn());
590 unsafe { &self.data.seq_sdefn }
591 }
592 #[allow(clippy::borrowed_box)]
593 pub fn as_seq_sdefn_mut(&mut self) -> &mut Box<PlainSequenceSElemDefn> {
594 debug_assert!(self.is_seq_sdefn());
595 unsafe { &mut self.data.seq_sdefn }
596 }
597 pub fn into_seq_sdefn(self) -> Box<PlainSequenceSElemDefn> {
598 debug_assert!(self.is_seq_sdefn());
599 unsafe {
600 let mut forget = core::mem::ManuallyDrop::new(self);
601 core::mem::ManuallyDrop::take(&mut forget.data.seq_sdefn)
602 }
603 }
604 pub fn new_seq_ldefn(value: Box<PlainSequenceLElemDefn>) -> Self {
605 Self {
606 tag: TI_PLAIN_SEQUENCE_LARGE,
607 data: TypeIdentifierData {
608 seq_ldefn: core::mem::ManuallyDrop::new(value),
609 },
610 }
611 }
612 pub fn is_seq_ldefn(&self) -> bool {
613 matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE)
614 }
615 #[allow(clippy::borrowed_box)]
616 pub fn as_seq_ldefn(&self) -> &Box<PlainSequenceLElemDefn> {
617 debug_assert!(self.is_seq_ldefn());
618 unsafe { &self.data.seq_ldefn }
619 }
620 #[allow(clippy::borrowed_box)]
621 pub fn as_seq_ldefn_mut(&mut self) -> &mut Box<PlainSequenceLElemDefn> {
622 debug_assert!(self.is_seq_ldefn());
623 unsafe { &mut self.data.seq_ldefn }
624 }
625 pub fn into_seq_ldefn(self) -> Box<PlainSequenceLElemDefn> {
626 debug_assert!(self.is_seq_ldefn());
627 unsafe {
628 let mut forget = core::mem::ManuallyDrop::new(self);
629 core::mem::ManuallyDrop::take(&mut forget.data.seq_ldefn)
630 }
631 }
632 pub fn new_array_sdefn(value: Box<PlainArraySElemDefn>) -> Self {
633 Self {
634 tag: TI_PLAIN_ARRAY_SMALL,
635 data: TypeIdentifierData {
636 array_sdefn: core::mem::ManuallyDrop::new(value),
637 },
638 }
639 }
640 pub fn is_array_sdefn(&self) -> bool {
641 matches!(self.tag, TI_PLAIN_ARRAY_SMALL)
642 }
643 #[allow(clippy::borrowed_box)]
644 pub fn as_array_sdefn(&self) -> &Box<PlainArraySElemDefn> {
645 debug_assert!(self.is_array_sdefn());
646 unsafe { &self.data.array_sdefn }
647 }
648 #[allow(clippy::borrowed_box)]
649 pub fn as_array_sdefn_mut(&mut self) -> &mut Box<PlainArraySElemDefn> {
650 debug_assert!(self.is_array_sdefn());
651 unsafe { &mut self.data.array_sdefn }
652 }
653 pub fn into_array_sdefn(self) -> Box<PlainArraySElemDefn> {
654 debug_assert!(self.is_array_sdefn());
655 unsafe {
656 let mut forget = core::mem::ManuallyDrop::new(self);
657 core::mem::ManuallyDrop::take(&mut forget.data.array_sdefn)
658 }
659 }
660 pub fn new_array_ldefn(value: Box<PlainArrayLElemDefn>) -> Self {
661 Self {
662 tag: TI_PLAIN_ARRAY_LARGE,
663 data: TypeIdentifierData {
664 array_ldefn: core::mem::ManuallyDrop::new(value),
665 },
666 }
667 }
668 pub fn is_array_ldefn(&self) -> bool {
669 matches!(self.tag, TI_PLAIN_ARRAY_LARGE)
670 }
671 #[allow(clippy::borrowed_box)]
672 pub fn as_array_ldefn(&self) -> &Box<PlainArrayLElemDefn> {
673 debug_assert!(self.is_array_ldefn());
674 unsafe { &self.data.array_ldefn }
675 }
676 #[allow(clippy::borrowed_box)]
677 pub fn as_array_ldefn_mut(&mut self) -> &mut Box<PlainArrayLElemDefn> {
678 debug_assert!(self.is_array_ldefn());
679 unsafe { &mut self.data.array_ldefn }
680 }
681 pub fn into_array_ldefn(self) -> Box<PlainArrayLElemDefn> {
682 debug_assert!(self.is_array_ldefn());
683 unsafe {
684 let mut forget = core::mem::ManuallyDrop::new(self);
685 core::mem::ManuallyDrop::take(&mut forget.data.array_ldefn)
686 }
687 }
688 pub fn new_map_sdefn(value: Box<PlainMapSTypeDefn>) -> Self {
689 Self {
690 tag: TI_PLAIN_MAP_SMALL,
691 data: TypeIdentifierData {
692 map_sdefn: core::mem::ManuallyDrop::new(value),
693 },
694 }
695 }
696 pub fn is_map_sdefn(&self) -> bool {
697 matches!(self.tag, TI_PLAIN_MAP_SMALL)
698 }
699 #[allow(clippy::borrowed_box)]
700 pub fn as_map_sdefn(&self) -> &Box<PlainMapSTypeDefn> {
701 debug_assert!(self.is_map_sdefn());
702 unsafe { &self.data.map_sdefn }
703 }
704 #[allow(clippy::borrowed_box)]
705 pub fn as_map_sdefn_mut(&mut self) -> &mut Box<PlainMapSTypeDefn> {
706 debug_assert!(self.is_map_sdefn());
707 unsafe { &mut self.data.map_sdefn }
708 }
709 pub fn into_map_sdefn(self) -> Box<PlainMapSTypeDefn> {
710 debug_assert!(self.is_map_sdefn());
711 unsafe {
712 let mut forget = core::mem::ManuallyDrop::new(self);
713 core::mem::ManuallyDrop::take(&mut forget.data.map_sdefn)
714 }
715 }
716 pub fn new_map_ldefn(value: Box<PlainMapLTypeDefn>) -> Self {
717 Self {
718 tag: TI_PLAIN_MAP_LARGE,
719 data: TypeIdentifierData {
720 map_ldefn: core::mem::ManuallyDrop::new(value),
721 },
722 }
723 }
724 pub fn is_map_ldefn(&self) -> bool {
725 matches!(self.tag, TI_PLAIN_MAP_LARGE)
726 }
727 #[allow(clippy::borrowed_box)]
728 pub fn as_map_ldefn(&self) -> &Box<PlainMapLTypeDefn> {
729 debug_assert!(self.is_map_ldefn());
730 unsafe { &self.data.map_ldefn }
731 }
732 #[allow(clippy::borrowed_box)]
733 pub fn as_map_ldefn_mut(&mut self) -> &mut Box<PlainMapLTypeDefn> {
734 debug_assert!(self.is_map_ldefn());
735 unsafe { &mut self.data.map_ldefn }
736 }
737 pub fn into_map_ldefn(self) -> Box<PlainMapLTypeDefn> {
738 debug_assert!(self.is_map_ldefn());
739 unsafe {
740 let mut forget = core::mem::ManuallyDrop::new(self);
741 core::mem::ManuallyDrop::take(&mut forget.data.map_ldefn)
742 }
743 }
744 pub fn new_sc_component_id(value: StronglyConnectedComponentId) -> Self {
745 Self {
746 tag: TI_STRONGLY_CONNECTED_COMPONENT,
747 data: TypeIdentifierData {
748 sc_component_id: core::mem::ManuallyDrop::new(value),
749 },
750 }
751 }
752 pub fn is_sc_component_id(&self) -> bool {
753 matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT)
754 }
755 #[allow(clippy::borrowed_box)]
756 pub fn as_sc_component_id(&self) -> &StronglyConnectedComponentId {
757 debug_assert!(self.is_sc_component_id());
758 unsafe { &self.data.sc_component_id }
759 }
760 #[allow(clippy::borrowed_box)]
761 pub fn as_sc_component_id_mut(&mut self) -> &mut StronglyConnectedComponentId {
762 debug_assert!(self.is_sc_component_id());
763 unsafe { &mut self.data.sc_component_id }
764 }
765 pub fn into_sc_component_id(self) -> StronglyConnectedComponentId {
766 debug_assert!(self.is_sc_component_id());
767 unsafe {
768 let mut forget = core::mem::ManuallyDrop::new(self);
769 core::mem::ManuallyDrop::take(&mut forget.data.sc_component_id)
770 }
771 }
772 pub fn new_equivalence_hash(value: EquivalenceHash) -> Self {
773 Self {
774 tag: EK_COMPLETE,
775 data: TypeIdentifierData {
776 equivalence_hash: core::mem::ManuallyDrop::new(value),
777 },
778 }
779 }
780 pub fn is_equivalence_hash(&self) -> bool {
781 matches!(self.tag, EK_COMPLETE | EK_MINIMAL)
782 }
783 #[allow(clippy::borrowed_box)]
784 pub fn as_equivalence_hash(&self) -> &EquivalenceHash {
785 debug_assert!(self.is_equivalence_hash());
786 unsafe { &self.data.equivalence_hash }
787 }
788 #[allow(clippy::borrowed_box)]
789 pub fn as_equivalence_hash_mut(&mut self) -> &mut EquivalenceHash {
790 debug_assert!(self.is_equivalence_hash());
791 unsafe { &mut self.data.equivalence_hash }
792 }
793 pub fn into_equivalence_hash(self) -> EquivalenceHash {
794 debug_assert!(self.is_equivalence_hash());
795 unsafe {
796 let mut forget = core::mem::ManuallyDrop::new(self);
797 core::mem::ManuallyDrop::take(&mut forget.data.equivalence_hash)
798 }
799 }
800 pub fn new_extended_defn(value: ExtendedTypeDefn) -> Self {
801 Self {
802 tag: u8::default(),
803 data: TypeIdentifierData {
804 extended_defn: core::mem::ManuallyDrop::new(value),
805 },
806 }
807 }
808 pub fn is_extended_defn(&self) -> bool {
809 matches!(self.tag, _)
810 }
811 #[allow(clippy::borrowed_box)]
812 pub fn as_extended_defn(&self) -> &ExtendedTypeDefn {
813 debug_assert!(self.is_extended_defn());
814 unsafe { &self.data.extended_defn }
815 }
816 #[allow(clippy::borrowed_box)]
817 pub fn as_extended_defn_mut(&mut self) -> &mut ExtendedTypeDefn {
818 debug_assert!(self.is_extended_defn());
819 unsafe { &mut self.data.extended_defn }
820 }
821 pub fn into_extended_defn(self) -> ExtendedTypeDefn {
822 debug_assert!(self.is_extended_defn());
823 unsafe {
824 let mut forget = core::mem::ManuallyDrop::new(self);
825 core::mem::ManuallyDrop::take(&mut forget.data.extended_defn)
826 }
827 }
828 pub fn tag(&self) -> &u8 {
829 &self.tag
830 }
831 }
832 impl Default for TypeIdentifier {
833 fn default() -> Self {
834 Self {
835 tag: u8::default(),
836 data: TypeIdentifierData {
837 extended_defn: core::mem::ManuallyDrop::new(ExtendedTypeDefn::default()),
838 },
839 }
840 }
841 }
842 #[derive(::serde::Serialize)]
843 struct TypeIdentifierSerdeRef<'__a> {
844 tag: &'__a str,
845 data: TypeIdentifierSerdeRefData<'__a>,
846 }
847 #[allow(clippy::borrowed_box)]
848 #[derive(::serde::Serialize)]
849 #[serde(untagged)]
850 enum TypeIdentifierSerdeRefData<'__a> {
851 Case0(&'__a StringSTypeDefn),
852 Case1(&'__a StringLTypeDefn),
853 Case2(&'__a Box<PlainSequenceSElemDefn>),
854 Case3(&'__a Box<PlainSequenceLElemDefn>),
855 Case4(&'__a Box<PlainArraySElemDefn>),
856 Case5(&'__a Box<PlainArrayLElemDefn>),
857 Case6(&'__a Box<PlainMapSTypeDefn>),
858 Case7(&'__a Box<PlainMapLTypeDefn>),
859 Case8(&'__a StronglyConnectedComponentId),
860 Case9(&'__a EquivalenceHash),
861 Case10(&'__a ExtendedTypeDefn),
862 }
863 impl serde::Serialize for TypeIdentifier {
864 #[allow(unreachable_patterns)]
865 fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
866 where
867 __S: serde::Serializer,
868 {
869 let helper = if matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL) {
870 let tag = match self.tag {
871 TI_STRING8_SMALL => "TI_STRING8_SMALL",
872 _ => "TI_STRING16_SMALL",
873 };
874 TypeIdentifierSerdeRef {
875 tag,
876 data: TypeIdentifierSerdeRefData::Case0(self.as_string_sdefn()),
877 }
878 } else if matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE) {
879 let tag = match self.tag {
880 TI_STRING8_LARGE => "TI_STRING8_LARGE",
881 _ => "TI_STRING16_LARGE",
882 };
883 TypeIdentifierSerdeRef {
884 tag,
885 data: TypeIdentifierSerdeRefData::Case1(self.as_string_ldefn()),
886 }
887 } else if matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL) {
888 let tag = "TI_PLAIN_SEQUENCE_SMALL";
889 TypeIdentifierSerdeRef {
890 tag,
891 data: TypeIdentifierSerdeRefData::Case2(self.as_seq_sdefn()),
892 }
893 } else if matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE) {
894 let tag = "TI_PLAIN_SEQUENCE_LARGE";
895 TypeIdentifierSerdeRef {
896 tag,
897 data: TypeIdentifierSerdeRefData::Case3(self.as_seq_ldefn()),
898 }
899 } else if matches!(self.tag, TI_PLAIN_ARRAY_SMALL) {
900 let tag = "TI_PLAIN_ARRAY_SMALL";
901 TypeIdentifierSerdeRef {
902 tag,
903 data: TypeIdentifierSerdeRefData::Case4(self.as_array_sdefn()),
904 }
905 } else if matches!(self.tag, TI_PLAIN_ARRAY_LARGE) {
906 let tag = "TI_PLAIN_ARRAY_LARGE";
907 TypeIdentifierSerdeRef {
908 tag,
909 data: TypeIdentifierSerdeRefData::Case5(self.as_array_ldefn()),
910 }
911 } else if matches!(self.tag, TI_PLAIN_MAP_SMALL) {
912 let tag = "TI_PLAIN_MAP_SMALL";
913 TypeIdentifierSerdeRef {
914 tag,
915 data: TypeIdentifierSerdeRefData::Case6(self.as_map_sdefn()),
916 }
917 } else if matches!(self.tag, TI_PLAIN_MAP_LARGE) {
918 let tag = "TI_PLAIN_MAP_LARGE";
919 TypeIdentifierSerdeRef {
920 tag,
921 data: TypeIdentifierSerdeRefData::Case7(self.as_map_ldefn()),
922 }
923 } else if matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT) {
924 let tag = "TI_STRONGLY_CONNECTED_COMPONENT";
925 TypeIdentifierSerdeRef {
926 tag,
927 data: TypeIdentifierSerdeRefData::Case8(self.as_sc_component_id()),
928 }
929 } else if matches!(self.tag, EK_COMPLETE | EK_MINIMAL) {
930 let tag = match self.tag {
931 EK_COMPLETE => "EK_COMPLETE",
932 _ => "EK_MINIMAL",
933 };
934 TypeIdentifierSerdeRef {
935 tag,
936 data: TypeIdentifierSerdeRefData::Case9(self.as_equivalence_hash()),
937 }
938 } else {
939 let tag = "default";
940 TypeIdentifierSerdeRef {
941 tag,
942 data: TypeIdentifierSerdeRefData::Case10(self.as_extended_defn()),
943 }
944 };
945 helper.serialize(__serializer)
946 }
947 }
948 #[derive(::serde::Deserialize)]
949 struct TypeIdentifierSerdeOwned {
950 tag: String,
951 data: ::serde_json::Value,
952 }
953 impl<'de> serde::Deserialize<'de> for TypeIdentifier {
954 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
955 where
956 D: serde::Deserializer<'de>,
957 {
958 let helper = TypeIdentifierSerdeOwned::deserialize(deserializer)?;
959 match helper.tag.as_str() {
960 "TI_STRING8_SMALL" => {
961 let value = ::serde_json::from_value::<
962 StringSTypeDefn,
963 >(helper.data)
964 .map_err(|err| serde::de::Error::custom(
965 format!(
966 "union TypeIdentifier payload decode failed for tag `TI_STRING8_SMALL`: {err}"
967 ),
968 ))?;
969 Ok(Self {
970 tag: TI_STRING8_SMALL,
971 data: TypeIdentifierData {
972 string_sdefn: core::mem::ManuallyDrop::new(value),
973 },
974 })
975 }
976 "TI_STRING16_SMALL" => {
977 let value = ::serde_json::from_value::<
978 StringSTypeDefn,
979 >(helper.data)
980 .map_err(|err| serde::de::Error::custom(
981 format!(
982 "union TypeIdentifier payload decode failed for tag `TI_STRING16_SMALL`: {err}"
983 ),
984 ))?;
985 Ok(Self {
986 tag: TI_STRING16_SMALL,
987 data: TypeIdentifierData {
988 string_sdefn: core::mem::ManuallyDrop::new(value),
989 },
990 })
991 }
992 "TI_STRING8_LARGE" => {
993 let value = ::serde_json::from_value::<
994 StringLTypeDefn,
995 >(helper.data)
996 .map_err(|err| serde::de::Error::custom(
997 format!(
998 "union TypeIdentifier payload decode failed for tag `TI_STRING8_LARGE`: {err}"
999 ),
1000 ))?;
1001 Ok(Self {
1002 tag: TI_STRING8_LARGE,
1003 data: TypeIdentifierData {
1004 string_ldefn: core::mem::ManuallyDrop::new(value),
1005 },
1006 })
1007 }
1008 "TI_STRING16_LARGE" => {
1009 let value = ::serde_json::from_value::<
1010 StringLTypeDefn,
1011 >(helper.data)
1012 .map_err(|err| serde::de::Error::custom(
1013 format!(
1014 "union TypeIdentifier payload decode failed for tag `TI_STRING16_LARGE`: {err}"
1015 ),
1016 ))?;
1017 Ok(Self {
1018 tag: TI_STRING16_LARGE,
1019 data: TypeIdentifierData {
1020 string_ldefn: core::mem::ManuallyDrop::new(value),
1021 },
1022 })
1023 }
1024 "TI_PLAIN_SEQUENCE_SMALL" => {
1025 let value = ::serde_json::from_value::<
1026 Box<PlainSequenceSElemDefn>,
1027 >(helper.data)
1028 .map_err(|err| serde::de::Error::custom(
1029 format!(
1030 "union TypeIdentifier payload decode failed for tag `TI_PLAIN_SEQUENCE_SMALL`: {err}"
1031 ),
1032 ))?;
1033 Ok(Self {
1034 tag: TI_PLAIN_SEQUENCE_SMALL,
1035 data: TypeIdentifierData {
1036 seq_sdefn: core::mem::ManuallyDrop::new(value),
1037 },
1038 })
1039 }
1040 "TI_PLAIN_SEQUENCE_LARGE" => {
1041 let value = ::serde_json::from_value::<
1042 Box<PlainSequenceLElemDefn>,
1043 >(helper.data)
1044 .map_err(|err| serde::de::Error::custom(
1045 format!(
1046 "union TypeIdentifier payload decode failed for tag `TI_PLAIN_SEQUENCE_LARGE`: {err}"
1047 ),
1048 ))?;
1049 Ok(Self {
1050 tag: TI_PLAIN_SEQUENCE_LARGE,
1051 data: TypeIdentifierData {
1052 seq_ldefn: core::mem::ManuallyDrop::new(value),
1053 },
1054 })
1055 }
1056 "TI_PLAIN_ARRAY_SMALL" => {
1057 let value = ::serde_json::from_value::<
1058 Box<PlainArraySElemDefn>,
1059 >(helper.data)
1060 .map_err(|err| serde::de::Error::custom(
1061 format!(
1062 "union TypeIdentifier payload decode failed for tag `TI_PLAIN_ARRAY_SMALL`: {err}"
1063 ),
1064 ))?;
1065 Ok(Self {
1066 tag: TI_PLAIN_ARRAY_SMALL,
1067 data: TypeIdentifierData {
1068 array_sdefn: core::mem::ManuallyDrop::new(value),
1069 },
1070 })
1071 }
1072 "TI_PLAIN_ARRAY_LARGE" => {
1073 let value = ::serde_json::from_value::<
1074 Box<PlainArrayLElemDefn>,
1075 >(helper.data)
1076 .map_err(|err| serde::de::Error::custom(
1077 format!(
1078 "union TypeIdentifier payload decode failed for tag `TI_PLAIN_ARRAY_LARGE`: {err}"
1079 ),
1080 ))?;
1081 Ok(Self {
1082 tag: TI_PLAIN_ARRAY_LARGE,
1083 data: TypeIdentifierData {
1084 array_ldefn: core::mem::ManuallyDrop::new(value),
1085 },
1086 })
1087 }
1088 "TI_PLAIN_MAP_SMALL" => {
1089 let value = ::serde_json::from_value::<
1090 Box<PlainMapSTypeDefn>,
1091 >(helper.data)
1092 .map_err(|err| serde::de::Error::custom(
1093 format!(
1094 "union TypeIdentifier payload decode failed for tag `TI_PLAIN_MAP_SMALL`: {err}"
1095 ),
1096 ))?;
1097 Ok(Self {
1098 tag: TI_PLAIN_MAP_SMALL,
1099 data: TypeIdentifierData {
1100 map_sdefn: core::mem::ManuallyDrop::new(value),
1101 },
1102 })
1103 }
1104 "TI_PLAIN_MAP_LARGE" => {
1105 let value = ::serde_json::from_value::<
1106 Box<PlainMapLTypeDefn>,
1107 >(helper.data)
1108 .map_err(|err| serde::de::Error::custom(
1109 format!(
1110 "union TypeIdentifier payload decode failed for tag `TI_PLAIN_MAP_LARGE`: {err}"
1111 ),
1112 ))?;
1113 Ok(Self {
1114 tag: TI_PLAIN_MAP_LARGE,
1115 data: TypeIdentifierData {
1116 map_ldefn: core::mem::ManuallyDrop::new(value),
1117 },
1118 })
1119 }
1120 "TI_STRONGLY_CONNECTED_COMPONENT" => {
1121 let value = ::serde_json::from_value::<
1122 StronglyConnectedComponentId,
1123 >(helper.data)
1124 .map_err(|err| serde::de::Error::custom(
1125 format!(
1126 "union TypeIdentifier payload decode failed for tag `TI_STRONGLY_CONNECTED_COMPONENT`: {err}"
1127 ),
1128 ))?;
1129 Ok(Self {
1130 tag: TI_STRONGLY_CONNECTED_COMPONENT,
1131 data: TypeIdentifierData {
1132 sc_component_id: core::mem::ManuallyDrop::new(value),
1133 },
1134 })
1135 }
1136 "EK_COMPLETE" => {
1137 let value = ::serde_json::from_value::<
1138 EquivalenceHash,
1139 >(helper.data)
1140 .map_err(|err| serde::de::Error::custom(
1141 format!(
1142 "union TypeIdentifier payload decode failed for tag `EK_COMPLETE`: {err}"
1143 ),
1144 ))?;
1145 Ok(Self {
1146 tag: EK_COMPLETE,
1147 data: TypeIdentifierData {
1148 equivalence_hash: core::mem::ManuallyDrop::new(value),
1149 },
1150 })
1151 }
1152 "EK_MINIMAL" => {
1153 let value = ::serde_json::from_value::<
1154 EquivalenceHash,
1155 >(helper.data)
1156 .map_err(|err| serde::de::Error::custom(
1157 format!(
1158 "union TypeIdentifier payload decode failed for tag `EK_MINIMAL`: {err}"
1159 ),
1160 ))?;
1161 Ok(Self {
1162 tag: EK_MINIMAL,
1163 data: TypeIdentifierData {
1164 equivalence_hash: core::mem::ManuallyDrop::new(value),
1165 },
1166 })
1167 }
1168 "default" => {
1169 let value = ::serde_json::from_value::<
1170 ExtendedTypeDefn,
1171 >(helper.data)
1172 .map_err(|err| serde::de::Error::custom(
1173 format!(
1174 "union TypeIdentifier payload decode failed for tag `default`: {err}"
1175 ),
1176 ))?;
1177 Ok(Self {
1178 tag: u8::default(),
1179 data: TypeIdentifierData {
1180 extended_defn: core::mem::ManuallyDrop::new(value),
1181 },
1182 })
1183 }
1184 _ => Err(serde::de::Error::custom(format!(
1185 "union TypeIdentifier tag/data mismatch for tag `{}`",
1186 helper.tag
1187 ))),
1188 }
1189 }
1190 }
1191 pub type TypeIdentifierSeq = Vec<TypeIdentifier>;
1192 pub type MemberId = u32;
1193 pub const ANNOTATION_STR_VALUE_MAX_LEN: u32 = 128;
1194 pub const ANNOTATION_OCTETSEC_VALUE_MAX_LEN: u32 = 128;
1195 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
1196 pub struct ExtendedAnnotationParameterValue {}
1197 impl ExtendedAnnotationParameterValue {}
1198 pub struct AnnotationParameterValue {
1199 tag: u8,
1200 data: AnnotationParameterValueData,
1201 }
1202 union AnnotationParameterValueData {
1203 boolean_value: core::mem::ManuallyDrop<bool>,
1204 byte_value: core::mem::ManuallyDrop<u8>,
1205 int16_value: core::mem::ManuallyDrop<i16>,
1206 uint_16_value: core::mem::ManuallyDrop<u16>,
1207 int32_value: core::mem::ManuallyDrop<i32>,
1208 uint32_value: core::mem::ManuallyDrop<u32>,
1209 int64_value: core::mem::ManuallyDrop<i64>,
1210 uint64_value: core::mem::ManuallyDrop<u64>,
1211 float32_value: core::mem::ManuallyDrop<f64>,
1212 float64_value: core::mem::ManuallyDrop<f64>,
1213 float128_value: core::mem::ManuallyDrop<f64>,
1214 char_value: core::mem::ManuallyDrop<char>,
1215 wchar_value: core::mem::ManuallyDrop<char>,
1216 enumerated_value: core::mem::ManuallyDrop<i32>,
1217 string8_value: core::mem::ManuallyDrop<String>,
1218 string16_value: core::mem::ManuallyDrop<String>,
1219 extended_value: core::mem::ManuallyDrop<ExtendedAnnotationParameterValue>,
1220 }
1221 impl Drop for AnnotationParameterValue {
1222 #[allow(unreachable_patterns)]
1223 fn drop(&mut self) {
1224 if matches!(self.tag, TK_BOOLEAN) {
1225 unsafe {
1226 core::mem::ManuallyDrop::drop(&mut self.data.boolean_value);
1227 }
1228 } else if matches!(self.tag, TK_BYTE) {
1229 unsafe {
1230 core::mem::ManuallyDrop::drop(&mut self.data.byte_value);
1231 }
1232 } else if matches!(self.tag, TK_INT16) {
1233 unsafe {
1234 core::mem::ManuallyDrop::drop(&mut self.data.int16_value);
1235 }
1236 } else if matches!(self.tag, TK_UINT16) {
1237 unsafe {
1238 core::mem::ManuallyDrop::drop(&mut self.data.uint_16_value);
1239 }
1240 } else if matches!(self.tag, TK_INT32) {
1241 unsafe {
1242 core::mem::ManuallyDrop::drop(&mut self.data.int32_value);
1243 }
1244 } else if matches!(self.tag, TK_UINT32) {
1245 unsafe {
1246 core::mem::ManuallyDrop::drop(&mut self.data.uint32_value);
1247 }
1248 } else if matches!(self.tag, TK_INT64) {
1249 unsafe {
1250 core::mem::ManuallyDrop::drop(&mut self.data.int64_value);
1251 }
1252 } else if matches!(self.tag, TK_UINT64) {
1253 unsafe {
1254 core::mem::ManuallyDrop::drop(&mut self.data.uint64_value);
1255 }
1256 } else if matches!(self.tag, TK_FLOAT32) {
1257 unsafe {
1258 core::mem::ManuallyDrop::drop(&mut self.data.float32_value);
1259 }
1260 } else if matches!(self.tag, TK_FLOAT64) {
1261 unsafe {
1262 core::mem::ManuallyDrop::drop(&mut self.data.float64_value);
1263 }
1264 } else if matches!(self.tag, TK_FLOAT128) {
1265 unsafe {
1266 core::mem::ManuallyDrop::drop(&mut self.data.float128_value);
1267 }
1268 } else if matches!(self.tag, TK_CHAR8) {
1269 unsafe {
1270 core::mem::ManuallyDrop::drop(&mut self.data.char_value);
1271 }
1272 } else if matches!(self.tag, TK_CHAR16) {
1273 unsafe {
1274 core::mem::ManuallyDrop::drop(&mut self.data.wchar_value);
1275 }
1276 } else if matches!(self.tag, TK_ENUM) {
1277 unsafe {
1278 core::mem::ManuallyDrop::drop(&mut self.data.enumerated_value);
1279 }
1280 } else if matches!(self.tag, TK_STRING8) {
1281 unsafe {
1282 core::mem::ManuallyDrop::drop(&mut self.data.string8_value);
1283 }
1284 } else if matches!(self.tag, TK_STRING16) {
1285 unsafe {
1286 core::mem::ManuallyDrop::drop(&mut self.data.string16_value);
1287 }
1288 } else {
1289 unsafe {
1290 core::mem::ManuallyDrop::drop(&mut self.data.extended_value);
1291 }
1292 }
1293 }
1294 }
1295 impl Clone for AnnotationParameterValue {
1296 #[allow(clippy::clone_on_copy)]
1297 #[allow(unreachable_patterns)]
1298 fn clone(&self) -> Self {
1299 if matches!(self.tag, TK_BOOLEAN) {
1300 Self::new_boolean_value(self.as_boolean_value().clone())
1301 } else if matches!(self.tag, TK_BYTE) {
1302 Self::new_byte_value(self.as_byte_value().clone())
1303 } else if matches!(self.tag, TK_INT16) {
1304 Self::new_int16_value(self.as_int16_value().clone())
1305 } else if matches!(self.tag, TK_UINT16) {
1306 Self::new_uint_16_value(self.as_uint_16_value().clone())
1307 } else if matches!(self.tag, TK_INT32) {
1308 Self::new_int32_value(self.as_int32_value().clone())
1309 } else if matches!(self.tag, TK_UINT32) {
1310 Self::new_uint32_value(self.as_uint32_value().clone())
1311 } else if matches!(self.tag, TK_INT64) {
1312 Self::new_int64_value(self.as_int64_value().clone())
1313 } else if matches!(self.tag, TK_UINT64) {
1314 Self::new_uint64_value(self.as_uint64_value().clone())
1315 } else if matches!(self.tag, TK_FLOAT32) {
1316 Self::new_float32_value(self.as_float32_value().clone())
1317 } else if matches!(self.tag, TK_FLOAT64) {
1318 Self::new_float64_value(self.as_float64_value().clone())
1319 } else if matches!(self.tag, TK_FLOAT128) {
1320 Self::new_float128_value(self.as_float128_value().clone())
1321 } else if matches!(self.tag, TK_CHAR8) {
1322 Self::new_char_value(self.as_char_value().clone())
1323 } else if matches!(self.tag, TK_CHAR16) {
1324 Self::new_wchar_value(self.as_wchar_value().clone())
1325 } else if matches!(self.tag, TK_ENUM) {
1326 Self::new_enumerated_value(self.as_enumerated_value().clone())
1327 } else if matches!(self.tag, TK_STRING8) {
1328 Self::new_string8_value(self.as_string8_value().clone())
1329 } else if matches!(self.tag, TK_STRING16) {
1330 Self::new_string16_value(self.as_string16_value().clone())
1331 } else {
1332 Self::new_extended_value(self.as_extended_value().clone())
1333 }
1334 }
1335 }
1336 impl core::fmt::Debug for AnnotationParameterValue {
1337 #[allow(unreachable_patterns)]
1338 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1339 let mut d = f.debug_struct("AnnotationParameterValue");
1340 d.field("tag", &self.tag);
1341 if matches!(self.tag, TK_BOOLEAN) {
1342 d.field("boolean_value", self.as_boolean_value());
1343 } else if matches!(self.tag, TK_BYTE) {
1344 d.field("byte_value", self.as_byte_value());
1345 } else if matches!(self.tag, TK_INT16) {
1346 d.field("int16_value", self.as_int16_value());
1347 } else if matches!(self.tag, TK_UINT16) {
1348 d.field("uint_16_value", self.as_uint_16_value());
1349 } else if matches!(self.tag, TK_INT32) {
1350 d.field("int32_value", self.as_int32_value());
1351 } else if matches!(self.tag, TK_UINT32) {
1352 d.field("uint32_value", self.as_uint32_value());
1353 } else if matches!(self.tag, TK_INT64) {
1354 d.field("int64_value", self.as_int64_value());
1355 } else if matches!(self.tag, TK_UINT64) {
1356 d.field("uint64_value", self.as_uint64_value());
1357 } else if matches!(self.tag, TK_FLOAT32) {
1358 d.field("float32_value", self.as_float32_value());
1359 } else if matches!(self.tag, TK_FLOAT64) {
1360 d.field("float64_value", self.as_float64_value());
1361 } else if matches!(self.tag, TK_FLOAT128) {
1362 d.field("float128_value", self.as_float128_value());
1363 } else if matches!(self.tag, TK_CHAR8) {
1364 d.field("char_value", self.as_char_value());
1365 } else if matches!(self.tag, TK_CHAR16) {
1366 d.field("wchar_value", self.as_wchar_value());
1367 } else if matches!(self.tag, TK_ENUM) {
1368 d.field("enumerated_value", self.as_enumerated_value());
1369 } else if matches!(self.tag, TK_STRING8) {
1370 d.field("string8_value", self.as_string8_value());
1371 } else if matches!(self.tag, TK_STRING16) {
1372 d.field("string16_value", self.as_string16_value());
1373 } else {
1374 d.field("extended_value", self.as_extended_value());
1375 }
1376 d.finish()
1377 }
1378 }
1379 impl PartialEq for AnnotationParameterValue {
1380 #[allow(unreachable_patterns)]
1381 fn eq(&self, other: &Self) -> bool {
1382 if self.tag != other.tag {
1383 return false;
1384 }
1385 if matches!(self.tag, TK_BOOLEAN) {
1386 self.as_boolean_value() == other.as_boolean_value()
1387 } else if matches!(self.tag, TK_BYTE) {
1388 self.as_byte_value() == other.as_byte_value()
1389 } else if matches!(self.tag, TK_INT16) {
1390 self.as_int16_value() == other.as_int16_value()
1391 } else if matches!(self.tag, TK_UINT16) {
1392 self.as_uint_16_value() == other.as_uint_16_value()
1393 } else if matches!(self.tag, TK_INT32) {
1394 self.as_int32_value() == other.as_int32_value()
1395 } else if matches!(self.tag, TK_UINT32) {
1396 self.as_uint32_value() == other.as_uint32_value()
1397 } else if matches!(self.tag, TK_INT64) {
1398 self.as_int64_value() == other.as_int64_value()
1399 } else if matches!(self.tag, TK_UINT64) {
1400 self.as_uint64_value() == other.as_uint64_value()
1401 } else if matches!(self.tag, TK_FLOAT32) {
1402 self.as_float32_value() == other.as_float32_value()
1403 } else if matches!(self.tag, TK_FLOAT64) {
1404 self.as_float64_value() == other.as_float64_value()
1405 } else if matches!(self.tag, TK_FLOAT128) {
1406 self.as_float128_value() == other.as_float128_value()
1407 } else if matches!(self.tag, TK_CHAR8) {
1408 self.as_char_value() == other.as_char_value()
1409 } else if matches!(self.tag, TK_CHAR16) {
1410 self.as_wchar_value() == other.as_wchar_value()
1411 } else if matches!(self.tag, TK_ENUM) {
1412 self.as_enumerated_value() == other.as_enumerated_value()
1413 } else if matches!(self.tag, TK_STRING8) {
1414 self.as_string8_value() == other.as_string8_value()
1415 } else if matches!(self.tag, TK_STRING16) {
1416 self.as_string16_value() == other.as_string16_value()
1417 } else {
1418 self.as_extended_value() == other.as_extended_value()
1419 }
1420 }
1421 }
1422 impl AnnotationParameterValue {
1423 pub fn new_boolean_value(value: bool) -> Self {
1424 Self {
1425 tag: TK_BOOLEAN,
1426 data: AnnotationParameterValueData {
1427 boolean_value: core::mem::ManuallyDrop::new(value),
1428 },
1429 }
1430 }
1431 pub fn is_boolean_value(&self) -> bool {
1432 matches!(self.tag, TK_BOOLEAN)
1433 }
1434 #[allow(clippy::borrowed_box)]
1435 pub fn as_boolean_value(&self) -> &bool {
1436 debug_assert!(self.is_boolean_value());
1437 unsafe { &self.data.boolean_value }
1438 }
1439 #[allow(clippy::borrowed_box)]
1440 pub fn as_boolean_value_mut(&mut self) -> &mut bool {
1441 debug_assert!(self.is_boolean_value());
1442 unsafe { &mut self.data.boolean_value }
1443 }
1444 pub fn into_boolean_value(self) -> bool {
1445 debug_assert!(self.is_boolean_value());
1446 unsafe {
1447 let mut forget = core::mem::ManuallyDrop::new(self);
1448 core::mem::ManuallyDrop::take(&mut forget.data.boolean_value)
1449 }
1450 }
1451 pub fn new_byte_value(value: u8) -> Self {
1452 Self {
1453 tag: TK_BYTE,
1454 data: AnnotationParameterValueData {
1455 byte_value: core::mem::ManuallyDrop::new(value),
1456 },
1457 }
1458 }
1459 pub fn is_byte_value(&self) -> bool {
1460 matches!(self.tag, TK_BYTE)
1461 }
1462 #[allow(clippy::borrowed_box)]
1463 pub fn as_byte_value(&self) -> &u8 {
1464 debug_assert!(self.is_byte_value());
1465 unsafe { &self.data.byte_value }
1466 }
1467 #[allow(clippy::borrowed_box)]
1468 pub fn as_byte_value_mut(&mut self) -> &mut u8 {
1469 debug_assert!(self.is_byte_value());
1470 unsafe { &mut self.data.byte_value }
1471 }
1472 pub fn into_byte_value(self) -> u8 {
1473 debug_assert!(self.is_byte_value());
1474 unsafe {
1475 let mut forget = core::mem::ManuallyDrop::new(self);
1476 core::mem::ManuallyDrop::take(&mut forget.data.byte_value)
1477 }
1478 }
1479 pub fn new_int16_value(value: i16) -> Self {
1480 Self {
1481 tag: TK_INT16,
1482 data: AnnotationParameterValueData {
1483 int16_value: core::mem::ManuallyDrop::new(value),
1484 },
1485 }
1486 }
1487 pub fn is_int16_value(&self) -> bool {
1488 matches!(self.tag, TK_INT16)
1489 }
1490 #[allow(clippy::borrowed_box)]
1491 pub fn as_int16_value(&self) -> &i16 {
1492 debug_assert!(self.is_int16_value());
1493 unsafe { &self.data.int16_value }
1494 }
1495 #[allow(clippy::borrowed_box)]
1496 pub fn as_int16_value_mut(&mut self) -> &mut i16 {
1497 debug_assert!(self.is_int16_value());
1498 unsafe { &mut self.data.int16_value }
1499 }
1500 pub fn into_int16_value(self) -> i16 {
1501 debug_assert!(self.is_int16_value());
1502 unsafe {
1503 let mut forget = core::mem::ManuallyDrop::new(self);
1504 core::mem::ManuallyDrop::take(&mut forget.data.int16_value)
1505 }
1506 }
1507 pub fn new_uint_16_value(value: u16) -> Self {
1508 Self {
1509 tag: TK_UINT16,
1510 data: AnnotationParameterValueData {
1511 uint_16_value: core::mem::ManuallyDrop::new(value),
1512 },
1513 }
1514 }
1515 pub fn is_uint_16_value(&self) -> bool {
1516 matches!(self.tag, TK_UINT16)
1517 }
1518 #[allow(clippy::borrowed_box)]
1519 pub fn as_uint_16_value(&self) -> &u16 {
1520 debug_assert!(self.is_uint_16_value());
1521 unsafe { &self.data.uint_16_value }
1522 }
1523 #[allow(clippy::borrowed_box)]
1524 pub fn as_uint_16_value_mut(&mut self) -> &mut u16 {
1525 debug_assert!(self.is_uint_16_value());
1526 unsafe { &mut self.data.uint_16_value }
1527 }
1528 pub fn into_uint_16_value(self) -> u16 {
1529 debug_assert!(self.is_uint_16_value());
1530 unsafe {
1531 let mut forget = core::mem::ManuallyDrop::new(self);
1532 core::mem::ManuallyDrop::take(&mut forget.data.uint_16_value)
1533 }
1534 }
1535 pub fn new_int32_value(value: i32) -> Self {
1536 Self {
1537 tag: TK_INT32,
1538 data: AnnotationParameterValueData {
1539 int32_value: core::mem::ManuallyDrop::new(value),
1540 },
1541 }
1542 }
1543 pub fn is_int32_value(&self) -> bool {
1544 matches!(self.tag, TK_INT32)
1545 }
1546 #[allow(clippy::borrowed_box)]
1547 pub fn as_int32_value(&self) -> &i32 {
1548 debug_assert!(self.is_int32_value());
1549 unsafe { &self.data.int32_value }
1550 }
1551 #[allow(clippy::borrowed_box)]
1552 pub fn as_int32_value_mut(&mut self) -> &mut i32 {
1553 debug_assert!(self.is_int32_value());
1554 unsafe { &mut self.data.int32_value }
1555 }
1556 pub fn into_int32_value(self) -> i32 {
1557 debug_assert!(self.is_int32_value());
1558 unsafe {
1559 let mut forget = core::mem::ManuallyDrop::new(self);
1560 core::mem::ManuallyDrop::take(&mut forget.data.int32_value)
1561 }
1562 }
1563 pub fn new_uint32_value(value: u32) -> Self {
1564 Self {
1565 tag: TK_UINT32,
1566 data: AnnotationParameterValueData {
1567 uint32_value: core::mem::ManuallyDrop::new(value),
1568 },
1569 }
1570 }
1571 pub fn is_uint32_value(&self) -> bool {
1572 matches!(self.tag, TK_UINT32)
1573 }
1574 #[allow(clippy::borrowed_box)]
1575 pub fn as_uint32_value(&self) -> &u32 {
1576 debug_assert!(self.is_uint32_value());
1577 unsafe { &self.data.uint32_value }
1578 }
1579 #[allow(clippy::borrowed_box)]
1580 pub fn as_uint32_value_mut(&mut self) -> &mut u32 {
1581 debug_assert!(self.is_uint32_value());
1582 unsafe { &mut self.data.uint32_value }
1583 }
1584 pub fn into_uint32_value(self) -> u32 {
1585 debug_assert!(self.is_uint32_value());
1586 unsafe {
1587 let mut forget = core::mem::ManuallyDrop::new(self);
1588 core::mem::ManuallyDrop::take(&mut forget.data.uint32_value)
1589 }
1590 }
1591 pub fn new_int64_value(value: i64) -> Self {
1592 Self {
1593 tag: TK_INT64,
1594 data: AnnotationParameterValueData {
1595 int64_value: core::mem::ManuallyDrop::new(value),
1596 },
1597 }
1598 }
1599 pub fn is_int64_value(&self) -> bool {
1600 matches!(self.tag, TK_INT64)
1601 }
1602 #[allow(clippy::borrowed_box)]
1603 pub fn as_int64_value(&self) -> &i64 {
1604 debug_assert!(self.is_int64_value());
1605 unsafe { &self.data.int64_value }
1606 }
1607 #[allow(clippy::borrowed_box)]
1608 pub fn as_int64_value_mut(&mut self) -> &mut i64 {
1609 debug_assert!(self.is_int64_value());
1610 unsafe { &mut self.data.int64_value }
1611 }
1612 pub fn into_int64_value(self) -> i64 {
1613 debug_assert!(self.is_int64_value());
1614 unsafe {
1615 let mut forget = core::mem::ManuallyDrop::new(self);
1616 core::mem::ManuallyDrop::take(&mut forget.data.int64_value)
1617 }
1618 }
1619 pub fn new_uint64_value(value: u64) -> Self {
1620 Self {
1621 tag: TK_UINT64,
1622 data: AnnotationParameterValueData {
1623 uint64_value: core::mem::ManuallyDrop::new(value),
1624 },
1625 }
1626 }
1627 pub fn is_uint64_value(&self) -> bool {
1628 matches!(self.tag, TK_UINT64)
1629 }
1630 #[allow(clippy::borrowed_box)]
1631 pub fn as_uint64_value(&self) -> &u64 {
1632 debug_assert!(self.is_uint64_value());
1633 unsafe { &self.data.uint64_value }
1634 }
1635 #[allow(clippy::borrowed_box)]
1636 pub fn as_uint64_value_mut(&mut self) -> &mut u64 {
1637 debug_assert!(self.is_uint64_value());
1638 unsafe { &mut self.data.uint64_value }
1639 }
1640 pub fn into_uint64_value(self) -> u64 {
1641 debug_assert!(self.is_uint64_value());
1642 unsafe {
1643 let mut forget = core::mem::ManuallyDrop::new(self);
1644 core::mem::ManuallyDrop::take(&mut forget.data.uint64_value)
1645 }
1646 }
1647 pub fn new_float32_value(value: f64) -> Self {
1648 Self {
1649 tag: TK_FLOAT32,
1650 data: AnnotationParameterValueData {
1651 float32_value: core::mem::ManuallyDrop::new(value),
1652 },
1653 }
1654 }
1655 pub fn is_float32_value(&self) -> bool {
1656 matches!(self.tag, TK_FLOAT32)
1657 }
1658 #[allow(clippy::borrowed_box)]
1659 pub fn as_float32_value(&self) -> &f64 {
1660 debug_assert!(self.is_float32_value());
1661 unsafe { &self.data.float32_value }
1662 }
1663 #[allow(clippy::borrowed_box)]
1664 pub fn as_float32_value_mut(&mut self) -> &mut f64 {
1665 debug_assert!(self.is_float32_value());
1666 unsafe { &mut self.data.float32_value }
1667 }
1668 pub fn into_float32_value(self) -> f64 {
1669 debug_assert!(self.is_float32_value());
1670 unsafe {
1671 let mut forget = core::mem::ManuallyDrop::new(self);
1672 core::mem::ManuallyDrop::take(&mut forget.data.float32_value)
1673 }
1674 }
1675 pub fn new_float64_value(value: f64) -> Self {
1676 Self {
1677 tag: TK_FLOAT64,
1678 data: AnnotationParameterValueData {
1679 float64_value: core::mem::ManuallyDrop::new(value),
1680 },
1681 }
1682 }
1683 pub fn is_float64_value(&self) -> bool {
1684 matches!(self.tag, TK_FLOAT64)
1685 }
1686 #[allow(clippy::borrowed_box)]
1687 pub fn as_float64_value(&self) -> &f64 {
1688 debug_assert!(self.is_float64_value());
1689 unsafe { &self.data.float64_value }
1690 }
1691 #[allow(clippy::borrowed_box)]
1692 pub fn as_float64_value_mut(&mut self) -> &mut f64 {
1693 debug_assert!(self.is_float64_value());
1694 unsafe { &mut self.data.float64_value }
1695 }
1696 pub fn into_float64_value(self) -> f64 {
1697 debug_assert!(self.is_float64_value());
1698 unsafe {
1699 let mut forget = core::mem::ManuallyDrop::new(self);
1700 core::mem::ManuallyDrop::take(&mut forget.data.float64_value)
1701 }
1702 }
1703 pub fn new_float128_value(value: f64) -> Self {
1704 Self {
1705 tag: TK_FLOAT128,
1706 data: AnnotationParameterValueData {
1707 float128_value: core::mem::ManuallyDrop::new(value),
1708 },
1709 }
1710 }
1711 pub fn is_float128_value(&self) -> bool {
1712 matches!(self.tag, TK_FLOAT128)
1713 }
1714 #[allow(clippy::borrowed_box)]
1715 pub fn as_float128_value(&self) -> &f64 {
1716 debug_assert!(self.is_float128_value());
1717 unsafe { &self.data.float128_value }
1718 }
1719 #[allow(clippy::borrowed_box)]
1720 pub fn as_float128_value_mut(&mut self) -> &mut f64 {
1721 debug_assert!(self.is_float128_value());
1722 unsafe { &mut self.data.float128_value }
1723 }
1724 pub fn into_float128_value(self) -> f64 {
1725 debug_assert!(self.is_float128_value());
1726 unsafe {
1727 let mut forget = core::mem::ManuallyDrop::new(self);
1728 core::mem::ManuallyDrop::take(&mut forget.data.float128_value)
1729 }
1730 }
1731 pub fn new_char_value(value: char) -> Self {
1732 Self {
1733 tag: TK_CHAR8,
1734 data: AnnotationParameterValueData {
1735 char_value: core::mem::ManuallyDrop::new(value),
1736 },
1737 }
1738 }
1739 pub fn is_char_value(&self) -> bool {
1740 matches!(self.tag, TK_CHAR8)
1741 }
1742 #[allow(clippy::borrowed_box)]
1743 pub fn as_char_value(&self) -> &char {
1744 debug_assert!(self.is_char_value());
1745 unsafe { &self.data.char_value }
1746 }
1747 #[allow(clippy::borrowed_box)]
1748 pub fn as_char_value_mut(&mut self) -> &mut char {
1749 debug_assert!(self.is_char_value());
1750 unsafe { &mut self.data.char_value }
1751 }
1752 pub fn into_char_value(self) -> char {
1753 debug_assert!(self.is_char_value());
1754 unsafe {
1755 let mut forget = core::mem::ManuallyDrop::new(self);
1756 core::mem::ManuallyDrop::take(&mut forget.data.char_value)
1757 }
1758 }
1759 pub fn new_wchar_value(value: char) -> Self {
1760 Self {
1761 tag: TK_CHAR16,
1762 data: AnnotationParameterValueData {
1763 wchar_value: core::mem::ManuallyDrop::new(value),
1764 },
1765 }
1766 }
1767 pub fn is_wchar_value(&self) -> bool {
1768 matches!(self.tag, TK_CHAR16)
1769 }
1770 #[allow(clippy::borrowed_box)]
1771 pub fn as_wchar_value(&self) -> &char {
1772 debug_assert!(self.is_wchar_value());
1773 unsafe { &self.data.wchar_value }
1774 }
1775 #[allow(clippy::borrowed_box)]
1776 pub fn as_wchar_value_mut(&mut self) -> &mut char {
1777 debug_assert!(self.is_wchar_value());
1778 unsafe { &mut self.data.wchar_value }
1779 }
1780 pub fn into_wchar_value(self) -> char {
1781 debug_assert!(self.is_wchar_value());
1782 unsafe {
1783 let mut forget = core::mem::ManuallyDrop::new(self);
1784 core::mem::ManuallyDrop::take(&mut forget.data.wchar_value)
1785 }
1786 }
1787 pub fn new_enumerated_value(value: i32) -> Self {
1788 Self {
1789 tag: TK_ENUM,
1790 data: AnnotationParameterValueData {
1791 enumerated_value: core::mem::ManuallyDrop::new(value),
1792 },
1793 }
1794 }
1795 pub fn is_enumerated_value(&self) -> bool {
1796 matches!(self.tag, TK_ENUM)
1797 }
1798 #[allow(clippy::borrowed_box)]
1799 pub fn as_enumerated_value(&self) -> &i32 {
1800 debug_assert!(self.is_enumerated_value());
1801 unsafe { &self.data.enumerated_value }
1802 }
1803 #[allow(clippy::borrowed_box)]
1804 pub fn as_enumerated_value_mut(&mut self) -> &mut i32 {
1805 debug_assert!(self.is_enumerated_value());
1806 unsafe { &mut self.data.enumerated_value }
1807 }
1808 pub fn into_enumerated_value(self) -> i32 {
1809 debug_assert!(self.is_enumerated_value());
1810 unsafe {
1811 let mut forget = core::mem::ManuallyDrop::new(self);
1812 core::mem::ManuallyDrop::take(&mut forget.data.enumerated_value)
1813 }
1814 }
1815 pub fn new_string8_value(value: String) -> Self {
1816 Self {
1817 tag: TK_STRING8,
1818 data: AnnotationParameterValueData {
1819 string8_value: core::mem::ManuallyDrop::new(value),
1820 },
1821 }
1822 }
1823 pub fn is_string8_value(&self) -> bool {
1824 matches!(self.tag, TK_STRING8)
1825 }
1826 #[allow(clippy::borrowed_box)]
1827 pub fn as_string8_value(&self) -> &String {
1828 debug_assert!(self.is_string8_value());
1829 unsafe { &self.data.string8_value }
1830 }
1831 #[allow(clippy::borrowed_box)]
1832 pub fn as_string8_value_mut(&mut self) -> &mut String {
1833 debug_assert!(self.is_string8_value());
1834 unsafe { &mut self.data.string8_value }
1835 }
1836 pub fn into_string8_value(self) -> String {
1837 debug_assert!(self.is_string8_value());
1838 unsafe {
1839 let mut forget = core::mem::ManuallyDrop::new(self);
1840 core::mem::ManuallyDrop::take(&mut forget.data.string8_value)
1841 }
1842 }
1843 pub fn new_string16_value(value: String) -> Self {
1844 Self {
1845 tag: TK_STRING16,
1846 data: AnnotationParameterValueData {
1847 string16_value: core::mem::ManuallyDrop::new(value),
1848 },
1849 }
1850 }
1851 pub fn is_string16_value(&self) -> bool {
1852 matches!(self.tag, TK_STRING16)
1853 }
1854 #[allow(clippy::borrowed_box)]
1855 pub fn as_string16_value(&self) -> &String {
1856 debug_assert!(self.is_string16_value());
1857 unsafe { &self.data.string16_value }
1858 }
1859 #[allow(clippy::borrowed_box)]
1860 pub fn as_string16_value_mut(&mut self) -> &mut String {
1861 debug_assert!(self.is_string16_value());
1862 unsafe { &mut self.data.string16_value }
1863 }
1864 pub fn into_string16_value(self) -> String {
1865 debug_assert!(self.is_string16_value());
1866 unsafe {
1867 let mut forget = core::mem::ManuallyDrop::new(self);
1868 core::mem::ManuallyDrop::take(&mut forget.data.string16_value)
1869 }
1870 }
1871 pub fn new_extended_value(value: ExtendedAnnotationParameterValue) -> Self {
1872 Self {
1873 tag: u8::default(),
1874 data: AnnotationParameterValueData {
1875 extended_value: core::mem::ManuallyDrop::new(value),
1876 },
1877 }
1878 }
1879 pub fn is_extended_value(&self) -> bool {
1880 matches!(self.tag, _)
1881 }
1882 #[allow(clippy::borrowed_box)]
1883 pub fn as_extended_value(&self) -> &ExtendedAnnotationParameterValue {
1884 debug_assert!(self.is_extended_value());
1885 unsafe { &self.data.extended_value }
1886 }
1887 #[allow(clippy::borrowed_box)]
1888 pub fn as_extended_value_mut(&mut self) -> &mut ExtendedAnnotationParameterValue {
1889 debug_assert!(self.is_extended_value());
1890 unsafe { &mut self.data.extended_value }
1891 }
1892 pub fn into_extended_value(self) -> ExtendedAnnotationParameterValue {
1893 debug_assert!(self.is_extended_value());
1894 unsafe {
1895 let mut forget = core::mem::ManuallyDrop::new(self);
1896 core::mem::ManuallyDrop::take(&mut forget.data.extended_value)
1897 }
1898 }
1899 pub fn tag(&self) -> &u8 {
1900 &self.tag
1901 }
1902 }
1903 impl Default for AnnotationParameterValue {
1904 fn default() -> Self {
1905 Self {
1906 tag: u8::default(),
1907 data: AnnotationParameterValueData {
1908 extended_value: core::mem::ManuallyDrop::new(
1909 ExtendedAnnotationParameterValue::default(),
1910 ),
1911 },
1912 }
1913 }
1914 }
1915 #[derive(::serde::Serialize)]
1916 struct AnnotationParameterValueSerdeRef<'__a> {
1917 tag: &'__a str,
1918 data: AnnotationParameterValueSerdeRefData<'__a>,
1919 }
1920 #[allow(clippy::borrowed_box)]
1921 #[derive(::serde::Serialize)]
1922 #[serde(untagged)]
1923 enum AnnotationParameterValueSerdeRefData<'__a> {
1924 Case0(&'__a bool),
1925 Case1(&'__a u8),
1926 Case2(&'__a i16),
1927 Case3(&'__a u16),
1928 Case4(&'__a i32),
1929 Case5(&'__a u32),
1930 Case6(&'__a i64),
1931 Case7(&'__a u64),
1932 Case8(&'__a f64),
1933 Case9(&'__a f64),
1934 Case10(&'__a f64),
1935 Case11(&'__a char),
1936 Case12(&'__a char),
1937 Case13(&'__a i32),
1938 Case14(&'__a String),
1939 Case15(&'__a String),
1940 Case16(&'__a ExtendedAnnotationParameterValue),
1941 }
1942 impl serde::Serialize for AnnotationParameterValue {
1943 #[allow(unreachable_patterns)]
1944 fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
1945 where
1946 __S: serde::Serializer,
1947 {
1948 let helper = if matches!(self.tag, TK_BOOLEAN) {
1949 let tag = "TK_BOOLEAN";
1950 AnnotationParameterValueSerdeRef {
1951 tag,
1952 data: AnnotationParameterValueSerdeRefData::Case0(self.as_boolean_value()),
1953 }
1954 } else if matches!(self.tag, TK_BYTE) {
1955 let tag = "TK_BYTE";
1956 AnnotationParameterValueSerdeRef {
1957 tag,
1958 data: AnnotationParameterValueSerdeRefData::Case1(self.as_byte_value()),
1959 }
1960 } else if matches!(self.tag, TK_INT16) {
1961 let tag = "TK_INT16";
1962 AnnotationParameterValueSerdeRef {
1963 tag,
1964 data: AnnotationParameterValueSerdeRefData::Case2(self.as_int16_value()),
1965 }
1966 } else if matches!(self.tag, TK_UINT16) {
1967 let tag = "TK_UINT16";
1968 AnnotationParameterValueSerdeRef {
1969 tag,
1970 data: AnnotationParameterValueSerdeRefData::Case3(self.as_uint_16_value()),
1971 }
1972 } else if matches!(self.tag, TK_INT32) {
1973 let tag = "TK_INT32";
1974 AnnotationParameterValueSerdeRef {
1975 tag,
1976 data: AnnotationParameterValueSerdeRefData::Case4(self.as_int32_value()),
1977 }
1978 } else if matches!(self.tag, TK_UINT32) {
1979 let tag = "TK_UINT32";
1980 AnnotationParameterValueSerdeRef {
1981 tag,
1982 data: AnnotationParameterValueSerdeRefData::Case5(self.as_uint32_value()),
1983 }
1984 } else if matches!(self.tag, TK_INT64) {
1985 let tag = "TK_INT64";
1986 AnnotationParameterValueSerdeRef {
1987 tag,
1988 data: AnnotationParameterValueSerdeRefData::Case6(self.as_int64_value()),
1989 }
1990 } else if matches!(self.tag, TK_UINT64) {
1991 let tag = "TK_UINT64";
1992 AnnotationParameterValueSerdeRef {
1993 tag,
1994 data: AnnotationParameterValueSerdeRefData::Case7(self.as_uint64_value()),
1995 }
1996 } else if matches!(self.tag, TK_FLOAT32) {
1997 let tag = "TK_FLOAT32";
1998 AnnotationParameterValueSerdeRef {
1999 tag,
2000 data: AnnotationParameterValueSerdeRefData::Case8(self.as_float32_value()),
2001 }
2002 } else if matches!(self.tag, TK_FLOAT64) {
2003 let tag = "TK_FLOAT64";
2004 AnnotationParameterValueSerdeRef {
2005 tag,
2006 data: AnnotationParameterValueSerdeRefData::Case9(self.as_float64_value()),
2007 }
2008 } else if matches!(self.tag, TK_FLOAT128) {
2009 let tag = "TK_FLOAT128";
2010 AnnotationParameterValueSerdeRef {
2011 tag,
2012 data: AnnotationParameterValueSerdeRefData::Case10(
2013 self.as_float128_value(),
2014 ),
2015 }
2016 } else if matches!(self.tag, TK_CHAR8) {
2017 let tag = "TK_CHAR8";
2018 AnnotationParameterValueSerdeRef {
2019 tag,
2020 data: AnnotationParameterValueSerdeRefData::Case11(self.as_char_value()),
2021 }
2022 } else if matches!(self.tag, TK_CHAR16) {
2023 let tag = "TK_CHAR16";
2024 AnnotationParameterValueSerdeRef {
2025 tag,
2026 data: AnnotationParameterValueSerdeRefData::Case12(self.as_wchar_value()),
2027 }
2028 } else if matches!(self.tag, TK_ENUM) {
2029 let tag = "TK_ENUM";
2030 AnnotationParameterValueSerdeRef {
2031 tag,
2032 data: AnnotationParameterValueSerdeRefData::Case13(
2033 self.as_enumerated_value(),
2034 ),
2035 }
2036 } else if matches!(self.tag, TK_STRING8) {
2037 let tag = "TK_STRING8";
2038 AnnotationParameterValueSerdeRef {
2039 tag,
2040 data: AnnotationParameterValueSerdeRefData::Case14(self.as_string8_value()),
2041 }
2042 } else if matches!(self.tag, TK_STRING16) {
2043 let tag = "TK_STRING16";
2044 AnnotationParameterValueSerdeRef {
2045 tag,
2046 data: AnnotationParameterValueSerdeRefData::Case15(
2047 self.as_string16_value(),
2048 ),
2049 }
2050 } else {
2051 let tag = "default";
2052 AnnotationParameterValueSerdeRef {
2053 tag,
2054 data: AnnotationParameterValueSerdeRefData::Case16(
2055 self.as_extended_value(),
2056 ),
2057 }
2058 };
2059 helper.serialize(__serializer)
2060 }
2061 }
2062 #[derive(::serde::Deserialize)]
2063 struct AnnotationParameterValueSerdeOwned {
2064 tag: String,
2065 data: ::serde_json::Value,
2066 }
2067 impl<'de> serde::Deserialize<'de> for AnnotationParameterValue {
2068 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
2069 where
2070 D: serde::Deserializer<'de>,
2071 {
2072 let helper = AnnotationParameterValueSerdeOwned::deserialize(deserializer)?;
2073 match helper.tag.as_str() {
2074 "TK_BOOLEAN" => {
2075 let value = ::serde_json::from_value::<bool>(helper.data)
2076 .map_err(|err| serde::de::Error::custom(
2077 format!(
2078 "union AnnotationParameterValue payload decode failed for tag `TK_BOOLEAN`: {err}"
2079 ),
2080 ))?;
2081 Ok(Self {
2082 tag: TK_BOOLEAN,
2083 data: AnnotationParameterValueData {
2084 boolean_value: core::mem::ManuallyDrop::new(value),
2085 },
2086 })
2087 }
2088 "TK_BYTE" => {
2089 let value = ::serde_json::from_value::<u8>(helper.data)
2090 .map_err(|err| serde::de::Error::custom(
2091 format!(
2092 "union AnnotationParameterValue payload decode failed for tag `TK_BYTE`: {err}"
2093 ),
2094 ))?;
2095 Ok(Self {
2096 tag: TK_BYTE,
2097 data: AnnotationParameterValueData {
2098 byte_value: core::mem::ManuallyDrop::new(value),
2099 },
2100 })
2101 }
2102 "TK_INT16" => {
2103 let value = ::serde_json::from_value::<i16>(helper.data)
2104 .map_err(|err| serde::de::Error::custom(
2105 format!(
2106 "union AnnotationParameterValue payload decode failed for tag `TK_INT16`: {err}"
2107 ),
2108 ))?;
2109 Ok(Self {
2110 tag: TK_INT16,
2111 data: AnnotationParameterValueData {
2112 int16_value: core::mem::ManuallyDrop::new(value),
2113 },
2114 })
2115 }
2116 "TK_UINT16" => {
2117 let value = ::serde_json::from_value::<u16>(helper.data)
2118 .map_err(|err| serde::de::Error::custom(
2119 format!(
2120 "union AnnotationParameterValue payload decode failed for tag `TK_UINT16`: {err}"
2121 ),
2122 ))?;
2123 Ok(Self {
2124 tag: TK_UINT16,
2125 data: AnnotationParameterValueData {
2126 uint_16_value: core::mem::ManuallyDrop::new(value),
2127 },
2128 })
2129 }
2130 "TK_INT32" => {
2131 let value = ::serde_json::from_value::<i32>(helper.data)
2132 .map_err(|err| serde::de::Error::custom(
2133 format!(
2134 "union AnnotationParameterValue payload decode failed for tag `TK_INT32`: {err}"
2135 ),
2136 ))?;
2137 Ok(Self {
2138 tag: TK_INT32,
2139 data: AnnotationParameterValueData {
2140 int32_value: core::mem::ManuallyDrop::new(value),
2141 },
2142 })
2143 }
2144 "TK_UINT32" => {
2145 let value = ::serde_json::from_value::<u32>(helper.data)
2146 .map_err(|err| serde::de::Error::custom(
2147 format!(
2148 "union AnnotationParameterValue payload decode failed for tag `TK_UINT32`: {err}"
2149 ),
2150 ))?;
2151 Ok(Self {
2152 tag: TK_UINT32,
2153 data: AnnotationParameterValueData {
2154 uint32_value: core::mem::ManuallyDrop::new(value),
2155 },
2156 })
2157 }
2158 "TK_INT64" => {
2159 let value = ::serde_json::from_value::<i64>(helper.data)
2160 .map_err(|err| serde::de::Error::custom(
2161 format!(
2162 "union AnnotationParameterValue payload decode failed for tag `TK_INT64`: {err}"
2163 ),
2164 ))?;
2165 Ok(Self {
2166 tag: TK_INT64,
2167 data: AnnotationParameterValueData {
2168 int64_value: core::mem::ManuallyDrop::new(value),
2169 },
2170 })
2171 }
2172 "TK_UINT64" => {
2173 let value = ::serde_json::from_value::<u64>(helper.data)
2174 .map_err(|err| serde::de::Error::custom(
2175 format!(
2176 "union AnnotationParameterValue payload decode failed for tag `TK_UINT64`: {err}"
2177 ),
2178 ))?;
2179 Ok(Self {
2180 tag: TK_UINT64,
2181 data: AnnotationParameterValueData {
2182 uint64_value: core::mem::ManuallyDrop::new(value),
2183 },
2184 })
2185 }
2186 "TK_FLOAT32" => {
2187 let value = ::serde_json::from_value::<f64>(helper.data)
2188 .map_err(|err| serde::de::Error::custom(
2189 format!(
2190 "union AnnotationParameterValue payload decode failed for tag `TK_FLOAT32`: {err}"
2191 ),
2192 ))?;
2193 Ok(Self {
2194 tag: TK_FLOAT32,
2195 data: AnnotationParameterValueData {
2196 float32_value: core::mem::ManuallyDrop::new(value),
2197 },
2198 })
2199 }
2200 "TK_FLOAT64" => {
2201 let value = ::serde_json::from_value::<f64>(helper.data)
2202 .map_err(|err| serde::de::Error::custom(
2203 format!(
2204 "union AnnotationParameterValue payload decode failed for tag `TK_FLOAT64`: {err}"
2205 ),
2206 ))?;
2207 Ok(Self {
2208 tag: TK_FLOAT64,
2209 data: AnnotationParameterValueData {
2210 float64_value: core::mem::ManuallyDrop::new(value),
2211 },
2212 })
2213 }
2214 "TK_FLOAT128" => {
2215 let value = ::serde_json::from_value::<f64>(helper.data)
2216 .map_err(|err| serde::de::Error::custom(
2217 format!(
2218 "union AnnotationParameterValue payload decode failed for tag `TK_FLOAT128`: {err}"
2219 ),
2220 ))?;
2221 Ok(Self {
2222 tag: TK_FLOAT128,
2223 data: AnnotationParameterValueData {
2224 float128_value: core::mem::ManuallyDrop::new(value),
2225 },
2226 })
2227 }
2228 "TK_CHAR8" => {
2229 let value = ::serde_json::from_value::<char>(helper.data)
2230 .map_err(|err| serde::de::Error::custom(
2231 format!(
2232 "union AnnotationParameterValue payload decode failed for tag `TK_CHAR8`: {err}"
2233 ),
2234 ))?;
2235 Ok(Self {
2236 tag: TK_CHAR8,
2237 data: AnnotationParameterValueData {
2238 char_value: core::mem::ManuallyDrop::new(value),
2239 },
2240 })
2241 }
2242 "TK_CHAR16" => {
2243 let value = ::serde_json::from_value::<char>(helper.data)
2244 .map_err(|err| serde::de::Error::custom(
2245 format!(
2246 "union AnnotationParameterValue payload decode failed for tag `TK_CHAR16`: {err}"
2247 ),
2248 ))?;
2249 Ok(Self {
2250 tag: TK_CHAR16,
2251 data: AnnotationParameterValueData {
2252 wchar_value: core::mem::ManuallyDrop::new(value),
2253 },
2254 })
2255 }
2256 "TK_ENUM" => {
2257 let value = ::serde_json::from_value::<i32>(helper.data)
2258 .map_err(|err| serde::de::Error::custom(
2259 format!(
2260 "union AnnotationParameterValue payload decode failed for tag `TK_ENUM`: {err}"
2261 ),
2262 ))?;
2263 Ok(Self {
2264 tag: TK_ENUM,
2265 data: AnnotationParameterValueData {
2266 enumerated_value: core::mem::ManuallyDrop::new(value),
2267 },
2268 })
2269 }
2270 "TK_STRING8" => {
2271 let value = ::serde_json::from_value::<String>(helper.data)
2272 .map_err(|err| serde::de::Error::custom(
2273 format!(
2274 "union AnnotationParameterValue payload decode failed for tag `TK_STRING8`: {err}"
2275 ),
2276 ))?;
2277 Ok(Self {
2278 tag: TK_STRING8,
2279 data: AnnotationParameterValueData {
2280 string8_value: core::mem::ManuallyDrop::new(value),
2281 },
2282 })
2283 }
2284 "TK_STRING16" => {
2285 let value = ::serde_json::from_value::<String>(helper.data)
2286 .map_err(|err| serde::de::Error::custom(
2287 format!(
2288 "union AnnotationParameterValue payload decode failed for tag `TK_STRING16`: {err}"
2289 ),
2290 ))?;
2291 Ok(Self {
2292 tag: TK_STRING16,
2293 data: AnnotationParameterValueData {
2294 string16_value: core::mem::ManuallyDrop::new(value),
2295 },
2296 })
2297 }
2298 "default" => {
2299 let value = ::serde_json::from_value::<
2300 ExtendedAnnotationParameterValue,
2301 >(helper.data)
2302 .map_err(|err| serde::de::Error::custom(
2303 format!(
2304 "union AnnotationParameterValue payload decode failed for tag `default`: {err}"
2305 ),
2306 ))?;
2307 Ok(Self {
2308 tag: u8::default(),
2309 data: AnnotationParameterValueData {
2310 extended_value: core::mem::ManuallyDrop::new(value),
2311 },
2312 })
2313 }
2314 _ => Err(serde::de::Error::custom(format!(
2315 "union AnnotationParameterValue tag/data mismatch for tag `{}`",
2316 helper.tag
2317 ))),
2318 }
2319 }
2320 }
2321 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2322 pub struct AppliedAnnotationParameter {
2323 pub paramname_hash: NameHash,
2324 pub value: AnnotationParameterValue,
2325 }
2326 impl AppliedAnnotationParameter {}
2327 pub type AppliedAnnotationParameterSeq = Vec<AppliedAnnotationParameter>;
2328 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2329 pub struct AppliedAnnotation {
2330 pub annotation_typeid: TypeIdentifier,
2331 pub param_seq: Option<AppliedAnnotationParameterSeq>,
2332 }
2333 impl AppliedAnnotation {}
2334 pub type AppliedAnnotationSeq = Vec<AppliedAnnotation>;
2335 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2336 pub struct AppliedVerbatimAnnotation {
2337 pub placement: String,
2338 pub language: String,
2339 pub text: String,
2340 }
2341 impl AppliedVerbatimAnnotation {}
2342 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2343 pub struct AppliedBuiltinMemberAnnotations {
2344 pub unit: Option<String>,
2345 pub min: Option<AnnotationParameterValue>,
2346 pub max: Option<AnnotationParameterValue>,
2347 pub hash_id: Option<String>,
2348 }
2349 impl AppliedBuiltinMemberAnnotations {}
2350 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2351 pub struct CommonStructMember {
2352 pub member_id: MemberId,
2353 pub member_flags: StructMemberFlag,
2354 pub member_type_id: TypeIdentifier,
2355 }
2356 impl CommonStructMember {}
2357 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2358 pub struct CompleteMemberDetail {
2359 pub name: MemberName,
2360 pub ann_builtin: Option<AppliedBuiltinMemberAnnotations>,
2361 pub ann_custom: Option<AppliedAnnotationSeq>,
2362 }
2363 impl CompleteMemberDetail {}
2364 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2365 pub struct MinimalMemberDetail {
2366 pub name_hash: NameHash,
2367 }
2368 impl MinimalMemberDetail {}
2369 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2370 pub struct CompleteStructMember {
2371 pub common: CommonStructMember,
2372 pub detail: CompleteMemberDetail,
2373 }
2374 impl CompleteStructMember {}
2375 pub type CompleteStructMemberSeq = Vec<CompleteStructMember>;
2376 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2377 pub struct MinimalStructMember {
2378 pub common: CommonStructMember,
2379 pub detail: MinimalMemberDetail,
2380 }
2381 impl MinimalStructMember {}
2382 pub type MinimalStructMemberSeq = Vec<MinimalStructMember>;
2383 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2384 pub struct AppliedBuiltinTypeAnnotations {
2385 pub verbatim: Option<AppliedVerbatimAnnotation>,
2386 }
2387 impl AppliedBuiltinTypeAnnotations {}
2388 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2389 pub struct MinimalTypeDetail {}
2390 impl MinimalTypeDetail {}
2391 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2392 pub struct CompleteTypeDetail {
2393 pub ann_builtin: Option<AppliedBuiltinTypeAnnotations>,
2394 pub ann_custom: Option<AppliedAnnotationSeq>,
2395 pub type_name: QualifiedTypeName,
2396 }
2397 impl CompleteTypeDetail {}
2398 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2399 pub struct CompleteStructHeader {
2400 pub base_type: TypeIdentifier,
2401 pub detail: CompleteTypeDetail,
2402 }
2403 impl CompleteStructHeader {}
2404 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2405 pub struct MinimalStructHeader {
2406 pub base_type: TypeIdentifier,
2407 pub detail: MinimalTypeDetail,
2408 }
2409 impl MinimalStructHeader {}
2410 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2411 pub struct CompleteStructType {
2412 pub struct_flags: StructTypeFlag,
2413 pub header: CompleteStructHeader,
2414 pub member_seq: CompleteStructMemberSeq,
2415 }
2416 impl CompleteStructType {}
2417 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2418 pub struct MinimalStructType {
2419 pub struct_flags: StructTypeFlag,
2420 pub header: MinimalStructHeader,
2421 pub member_seq: MinimalStructMemberSeq,
2422 }
2423 impl MinimalStructType {}
2424 pub type UnionCaseLabelSeq = Vec<i32>;
2425 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2426 pub struct CommonUnionMember {
2427 pub member_id: MemberId,
2428 pub member_flags: UnionMemberFlag,
2429 pub type_id: TypeIdentifier,
2430 pub label_seq: UnionCaseLabelSeq,
2431 }
2432 impl CommonUnionMember {}
2433 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2434 pub struct CompleteUnionMember {
2435 pub common: CommonUnionMember,
2436 pub detail: CompleteMemberDetail,
2437 }
2438 impl CompleteUnionMember {}
2439 pub type CompleteUnionMemberSeq = Vec<CompleteUnionMember>;
2440 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2441 pub struct MinimalUnionMember {
2442 pub common: CommonUnionMember,
2443 pub detail: MinimalMemberDetail,
2444 }
2445 impl MinimalUnionMember {}
2446 pub type MinimalUnionMemberSeq = Vec<MinimalUnionMember>;
2447 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2448 pub struct CommonDiscriminatorMember {
2449 pub member_flags: UnionDiscriminatorFlag,
2450 pub type_id: TypeIdentifier,
2451 }
2452 impl CommonDiscriminatorMember {}
2453 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2454 pub struct CompleteDiscriminatorMember {
2455 pub common: CommonDiscriminatorMember,
2456 pub ann_builtin: Option<AppliedBuiltinTypeAnnotations>,
2457 pub ann_custom: Option<AppliedAnnotationSeq>,
2458 }
2459 impl CompleteDiscriminatorMember {}
2460 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2461 pub struct MinimalDiscriminatorMember {
2462 pub common: CommonDiscriminatorMember,
2463 }
2464 impl MinimalDiscriminatorMember {}
2465 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2466 pub struct CompleteUnionHeader {
2467 pub detail: CompleteTypeDetail,
2468 }
2469 impl CompleteUnionHeader {}
2470 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2471 pub struct MinimalUnionHeader {
2472 pub detail: MinimalTypeDetail,
2473 }
2474 impl MinimalUnionHeader {}
2475 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2476 pub struct CompleteUnionType {
2477 pub union_flags: UnionTypeFlag,
2478 pub header: CompleteUnionHeader,
2479 pub discriminator: CompleteDiscriminatorMember,
2480 pub member_seq: CompleteUnionMemberSeq,
2481 }
2482 impl CompleteUnionType {}
2483 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2484 pub struct MinimalUnionType {
2485 pub union_flags: UnionTypeFlag,
2486 pub header: MinimalUnionHeader,
2487 pub discriminator: MinimalDiscriminatorMember,
2488 pub member_seq: MinimalUnionMemberSeq,
2489 }
2490 impl MinimalUnionType {}
2491 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2492 pub struct CommonAnnotationParameter {
2493 pub member_flags: AnnotationParameterFlag,
2494 pub member_type_id: TypeIdentifier,
2495 }
2496 impl CommonAnnotationParameter {}
2497 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2498 pub struct CompleteAnnotationParameter {
2499 pub common: CommonAnnotationParameter,
2500 pub name: MemberName,
2501 pub default_value: AnnotationParameterValue,
2502 }
2503 impl CompleteAnnotationParameter {}
2504 pub type CompleteAnnotationParameterSeq = Vec<CompleteAnnotationParameter>;
2505 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2506 pub struct MinimalAnnotationParameter {
2507 pub common: CommonAnnotationParameter,
2508 pub name_hash: NameHash,
2509 pub default_value: AnnotationParameterValue,
2510 }
2511 impl MinimalAnnotationParameter {}
2512 pub type MinimalAnnotationParameterSeq = Vec<MinimalAnnotationParameter>;
2513 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2514 pub struct CompleteAnnotationHeader {
2515 pub annotation_name: QualifiedTypeName,
2516 }
2517 impl CompleteAnnotationHeader {}
2518 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2519 pub struct MinimalAnnotationHeader {}
2520 impl MinimalAnnotationHeader {}
2521 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2522 pub struct CompleteAnnotationType {
2523 pub annotation_flag: AnnotationTypeFlag,
2524 pub header: CompleteAnnotationHeader,
2525 pub member_seq: CompleteAnnotationParameterSeq,
2526 }
2527 impl CompleteAnnotationType {}
2528 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2529 pub struct MinimalAnnotationType {
2530 pub annotation_flag: AnnotationTypeFlag,
2531 pub header: MinimalAnnotationHeader,
2532 pub member_seq: MinimalAnnotationParameterSeq,
2533 }
2534 impl MinimalAnnotationType {}
2535 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2536 pub struct CommonAliasBody {
2537 pub related_flags: AliasMemberFlag,
2538 pub related_type: TypeIdentifier,
2539 }
2540 impl CommonAliasBody {}
2541 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2542 pub struct CompleteAliasBody {
2543 pub common: CommonAliasBody,
2544 pub ann_builtin: Option<AppliedBuiltinMemberAnnotations>,
2545 pub ann_custom: Option<AppliedAnnotationSeq>,
2546 }
2547 impl CompleteAliasBody {}
2548 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2549 pub struct MinimalAliasBody {
2550 pub common: CommonAliasBody,
2551 }
2552 impl MinimalAliasBody {}
2553 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2554 pub struct CompleteAliasHeader {
2555 pub detail: CompleteTypeDetail,
2556 }
2557 impl CompleteAliasHeader {}
2558 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2559 pub struct MinimalAliasHeader {}
2560 impl MinimalAliasHeader {}
2561 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2562 pub struct CompleteAliasType {
2563 pub alias_flags: AliasTypeFlag,
2564 pub header: CompleteAliasHeader,
2565 pub body: CompleteAliasBody,
2566 }
2567 impl CompleteAliasType {}
2568 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2569 pub struct MinimalAliasType {
2570 pub alias_flags: AliasTypeFlag,
2571 pub header: MinimalAliasHeader,
2572 pub body: MinimalAliasBody,
2573 }
2574 impl MinimalAliasType {}
2575 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2576 pub struct CompleteElementDetail {
2577 pub ann_builtin: Option<AppliedBuiltinMemberAnnotations>,
2578 pub ann_custom: Option<AppliedAnnotationSeq>,
2579 }
2580 impl CompleteElementDetail {}
2581 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2582 pub struct CommonCollectionElement {
2583 pub element_flags: CollectionElementFlag,
2584 pub r#type: TypeIdentifier,
2585 }
2586 impl CommonCollectionElement {}
2587 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2588 pub struct CompleteCollectionElement {
2589 pub common: CommonCollectionElement,
2590 pub detail: CompleteElementDetail,
2591 }
2592 impl CompleteCollectionElement {}
2593 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2594 pub struct MinimalCollectionElement {
2595 pub common: CommonCollectionElement,
2596 }
2597 impl MinimalCollectionElement {}
2598 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2599 pub struct CommonCollectionHeader {
2600 pub bound: LBound,
2601 }
2602 impl CommonCollectionHeader {}
2603 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2604 pub struct CompleteCollectionHeader {
2605 pub common: CommonCollectionHeader,
2606 pub detail: Option<CompleteTypeDetail>,
2607 }
2608 impl CompleteCollectionHeader {}
2609 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2610 pub struct MinimalCollectionHeader {
2611 pub common: CommonCollectionHeader,
2612 }
2613 impl MinimalCollectionHeader {}
2614 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2615 pub struct CompleteSequenceType {
2616 pub collection_flag: CollectionTypeFlag,
2617 pub header: CompleteCollectionHeader,
2618 pub element: CompleteCollectionElement,
2619 }
2620 impl CompleteSequenceType {}
2621 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2622 pub struct MinimalSequenceType {
2623 pub collection_flag: CollectionTypeFlag,
2624 pub header: MinimalCollectionHeader,
2625 pub element: MinimalCollectionElement,
2626 }
2627 impl MinimalSequenceType {}
2628 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2629 pub struct CommonArrayHeader {
2630 pub bound_seq: LBoundSeq,
2631 }
2632 impl CommonArrayHeader {}
2633 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2634 pub struct CompleteArrayHeader {
2635 pub common: CommonArrayHeader,
2636 pub detail: CompleteTypeDetail,
2637 }
2638 impl CompleteArrayHeader {}
2639 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2640 pub struct MinimalArrayHeader {
2641 pub common: CommonArrayHeader,
2642 }
2643 impl MinimalArrayHeader {}
2644 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2645 pub struct CompleteArrayType {
2646 pub collection_flag: CollectionTypeFlag,
2647 pub header: CompleteArrayHeader,
2648 pub element: CompleteCollectionElement,
2649 }
2650 impl CompleteArrayType {}
2651 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2652 pub struct MinimalArrayType {
2653 pub collection_flag: CollectionTypeFlag,
2654 pub header: MinimalArrayHeader,
2655 pub element: MinimalCollectionElement,
2656 }
2657 impl MinimalArrayType {}
2658 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2659 pub struct CompleteMapType {
2660 pub collection_flag: CollectionTypeFlag,
2661 pub header: CompleteCollectionHeader,
2662 pub key: CompleteCollectionElement,
2663 pub element: CompleteCollectionElement,
2664 }
2665 impl CompleteMapType {}
2666 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2667 pub struct MinimalMapType {
2668 pub collection_flag: CollectionTypeFlag,
2669 pub header: MinimalCollectionHeader,
2670 pub key: MinimalCollectionElement,
2671 pub element: MinimalCollectionElement,
2672 }
2673 impl MinimalMapType {}
2674 pub type BitBound = u16;
2675 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2676 pub struct CommonEnumeratedLiteral {
2677 pub value: i32,
2678 pub flags: EnumeratedLiteralFlag,
2679 }
2680 impl CommonEnumeratedLiteral {}
2681 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2682 pub struct CompleteEnumeratedLiteral {
2683 pub common: CommonEnumeratedLiteral,
2684 pub detail: CompleteMemberDetail,
2685 }
2686 impl CompleteEnumeratedLiteral {}
2687 pub type CompleteEnumeratedLiteralSeq = Vec<CompleteEnumeratedLiteral>;
2688 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2689 pub struct MinimalEnumeratedLiteral {
2690 pub common: CommonEnumeratedLiteral,
2691 pub detail: MinimalMemberDetail,
2692 }
2693 impl MinimalEnumeratedLiteral {}
2694 pub type MinimalEnumeratedLiteralSeq = Vec<MinimalEnumeratedLiteral>;
2695 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2696 pub struct CommonEnumeratedHeader {
2697 pub bit_bound: BitBound,
2698 }
2699 impl CommonEnumeratedHeader {}
2700 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2701 pub struct CompleteEnumeratedHeader {
2702 pub common: CommonEnumeratedHeader,
2703 pub detail: CompleteTypeDetail,
2704 }
2705 impl CompleteEnumeratedHeader {}
2706 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2707 pub struct MinimalEnumeratedHeader {
2708 pub common: CommonEnumeratedHeader,
2709 }
2710 impl MinimalEnumeratedHeader {}
2711 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2712 pub struct CompleteEnumeratedType {
2713 pub enum_flags: EnumTypeFlag,
2714 pub header: CompleteEnumeratedHeader,
2715 pub literal_seq: CompleteEnumeratedLiteralSeq,
2716 }
2717 impl CompleteEnumeratedType {}
2718 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2719 pub struct MinimalEnumeratedType {
2720 pub enum_flags: EnumTypeFlag,
2721 pub header: MinimalEnumeratedHeader,
2722 pub literal_seq: MinimalEnumeratedLiteralSeq,
2723 }
2724 impl MinimalEnumeratedType {}
2725 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2726 pub struct CommonBitflag {
2727 pub position: u16,
2728 pub flags: BitflagFlag,
2729 }
2730 impl CommonBitflag {}
2731 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2732 pub struct CompleteBitflag {
2733 pub common: CommonBitflag,
2734 pub detail: CompleteMemberDetail,
2735 }
2736 impl CompleteBitflag {}
2737 pub type CompleteBitflagSeq = Vec<CompleteBitflag>;
2738 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2739 pub struct MinimalBitflag {
2740 pub common: CommonBitflag,
2741 pub detail: MinimalMemberDetail,
2742 }
2743 impl MinimalBitflag {}
2744 pub type MinimalBitflagSeq = Vec<MinimalBitflag>;
2745 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2746 pub struct CommonBitmaskHeader {
2747 pub bit_bound: BitBound,
2748 }
2749 impl CommonBitmaskHeader {}
2750 pub type CompleteBitmaskHeader = CompleteEnumeratedHeader;
2751 pub type MinimalBitmaskHeader = MinimalEnumeratedHeader;
2752 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2753 pub struct CompleteBitmaskType {
2754 pub bitmask_flags: BitmaskTypeFlag,
2755 pub header: CompleteBitmaskHeader,
2756 pub flag_seq: CompleteBitflagSeq,
2757 }
2758 impl CompleteBitmaskType {}
2759 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2760 pub struct MinimalBitmaskType {
2761 pub bitmask_flags: BitmaskTypeFlag,
2762 pub header: MinimalBitmaskHeader,
2763 pub flag_seq: MinimalBitflagSeq,
2764 }
2765 impl MinimalBitmaskType {}
2766 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2767 pub struct CommonBitfield {
2768 pub position: u16,
2769 pub flags: BitsetMemberFlag,
2770 pub bitcount: u8,
2771 pub holder_type: TypeKind,
2772 }
2773 impl CommonBitfield {}
2774 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2775 pub struct CompleteBitfield {
2776 pub common: CommonBitfield,
2777 pub detail: CompleteMemberDetail,
2778 }
2779 impl CompleteBitfield {}
2780 pub type CompleteBitfieldSeq = Vec<CompleteBitfield>;
2781 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2782 pub struct MinimalBitfield {
2783 pub common: CommonBitfield,
2784 pub name_hash: NameHash,
2785 }
2786 impl MinimalBitfield {}
2787 pub type MinimalBitfieldSeq = Vec<MinimalBitfield>;
2788 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2789 pub struct CompleteBitsetHeader {
2790 pub detail: CompleteTypeDetail,
2791 }
2792 impl CompleteBitsetHeader {}
2793 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2794 pub struct MinimalBitsetHeader {}
2795 impl MinimalBitsetHeader {}
2796 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2797 pub struct CompleteBitsetType {
2798 pub bitset_flags: BitsetTypeFlag,
2799 pub header: CompleteBitsetHeader,
2800 pub field_seq: CompleteBitfieldSeq,
2801 }
2802 impl CompleteBitsetType {}
2803 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2804 pub struct MinimalBitsetType {
2805 pub bitset_flags: BitsetTypeFlag,
2806 pub header: MinimalBitsetHeader,
2807 pub field_seq: MinimalBitfieldSeq,
2808 }
2809 impl MinimalBitsetType {}
2810 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
2811 pub struct CompleteExtendedType {}
2812 impl CompleteExtendedType {}
2813 pub struct CompleteTypeObject {
2814 tag: u8,
2815 data: CompleteTypeObjectData,
2816 }
2817 union CompleteTypeObjectData {
2818 alias_type: core::mem::ManuallyDrop<CompleteAliasType>,
2819 annotation_type: core::mem::ManuallyDrop<CompleteAnnotationType>,
2820 struct_type: core::mem::ManuallyDrop<CompleteStructType>,
2821 union_type: core::mem::ManuallyDrop<CompleteUnionType>,
2822 bitset_type: core::mem::ManuallyDrop<CompleteBitsetType>,
2823 sequence_type: core::mem::ManuallyDrop<CompleteSequenceType>,
2824 array_type: core::mem::ManuallyDrop<CompleteArrayType>,
2825 map_type: core::mem::ManuallyDrop<CompleteMapType>,
2826 enumerated_type: core::mem::ManuallyDrop<CompleteEnumeratedType>,
2827 bitmask_type: core::mem::ManuallyDrop<CompleteBitmaskType>,
2828 extended_type: core::mem::ManuallyDrop<CompleteExtendedType>,
2829 }
2830 impl Drop for CompleteTypeObject {
2831 #[allow(unreachable_patterns)]
2832 fn drop(&mut self) {
2833 if matches!(self.tag, TK_ALIAS) {
2834 unsafe {
2835 core::mem::ManuallyDrop::drop(&mut self.data.alias_type);
2836 }
2837 } else if matches!(self.tag, TK_ANNOTATION) {
2838 unsafe {
2839 core::mem::ManuallyDrop::drop(&mut self.data.annotation_type);
2840 }
2841 } else if matches!(self.tag, TK_STRUCTURE) {
2842 unsafe {
2843 core::mem::ManuallyDrop::drop(&mut self.data.struct_type);
2844 }
2845 } else if matches!(self.tag, TK_UNION) {
2846 unsafe {
2847 core::mem::ManuallyDrop::drop(&mut self.data.union_type);
2848 }
2849 } else if matches!(self.tag, TK_BITSET) {
2850 unsafe {
2851 core::mem::ManuallyDrop::drop(&mut self.data.bitset_type);
2852 }
2853 } else if matches!(self.tag, TK_SEQUENCE) {
2854 unsafe {
2855 core::mem::ManuallyDrop::drop(&mut self.data.sequence_type);
2856 }
2857 } else if matches!(self.tag, TK_ARRAY) {
2858 unsafe {
2859 core::mem::ManuallyDrop::drop(&mut self.data.array_type);
2860 }
2861 } else if matches!(self.tag, TK_MAP) {
2862 unsafe {
2863 core::mem::ManuallyDrop::drop(&mut self.data.map_type);
2864 }
2865 } else if matches!(self.tag, TK_ENUM) {
2866 unsafe {
2867 core::mem::ManuallyDrop::drop(&mut self.data.enumerated_type);
2868 }
2869 } else if matches!(self.tag, TK_BITMASK) {
2870 unsafe {
2871 core::mem::ManuallyDrop::drop(&mut self.data.bitmask_type);
2872 }
2873 } else {
2874 unsafe {
2875 core::mem::ManuallyDrop::drop(&mut self.data.extended_type);
2876 }
2877 }
2878 }
2879 }
2880 impl Clone for CompleteTypeObject {
2881 #[allow(clippy::clone_on_copy)]
2882 #[allow(unreachable_patterns)]
2883 fn clone(&self) -> Self {
2884 if matches!(self.tag, TK_ALIAS) {
2885 Self::new_alias_type(self.as_alias_type().clone())
2886 } else if matches!(self.tag, TK_ANNOTATION) {
2887 Self::new_annotation_type(self.as_annotation_type().clone())
2888 } else if matches!(self.tag, TK_STRUCTURE) {
2889 Self::new_struct_type(self.as_struct_type().clone())
2890 } else if matches!(self.tag, TK_UNION) {
2891 Self::new_union_type(self.as_union_type().clone())
2892 } else if matches!(self.tag, TK_BITSET) {
2893 Self::new_bitset_type(self.as_bitset_type().clone())
2894 } else if matches!(self.tag, TK_SEQUENCE) {
2895 Self::new_sequence_type(self.as_sequence_type().clone())
2896 } else if matches!(self.tag, TK_ARRAY) {
2897 Self::new_array_type(self.as_array_type().clone())
2898 } else if matches!(self.tag, TK_MAP) {
2899 Self::new_map_type(self.as_map_type().clone())
2900 } else if matches!(self.tag, TK_ENUM) {
2901 Self::new_enumerated_type(self.as_enumerated_type().clone())
2902 } else if matches!(self.tag, TK_BITMASK) {
2903 Self::new_bitmask_type(self.as_bitmask_type().clone())
2904 } else {
2905 Self::new_extended_type(self.as_extended_type().clone())
2906 }
2907 }
2908 }
2909 impl core::fmt::Debug for CompleteTypeObject {
2910 #[allow(unreachable_patterns)]
2911 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
2912 let mut d = f.debug_struct("CompleteTypeObject");
2913 d.field("tag", &self.tag);
2914 if matches!(self.tag, TK_ALIAS) {
2915 d.field("alias_type", self.as_alias_type());
2916 } else if matches!(self.tag, TK_ANNOTATION) {
2917 d.field("annotation_type", self.as_annotation_type());
2918 } else if matches!(self.tag, TK_STRUCTURE) {
2919 d.field("struct_type", self.as_struct_type());
2920 } else if matches!(self.tag, TK_UNION) {
2921 d.field("union_type", self.as_union_type());
2922 } else if matches!(self.tag, TK_BITSET) {
2923 d.field("bitset_type", self.as_bitset_type());
2924 } else if matches!(self.tag, TK_SEQUENCE) {
2925 d.field("sequence_type", self.as_sequence_type());
2926 } else if matches!(self.tag, TK_ARRAY) {
2927 d.field("array_type", self.as_array_type());
2928 } else if matches!(self.tag, TK_MAP) {
2929 d.field("map_type", self.as_map_type());
2930 } else if matches!(self.tag, TK_ENUM) {
2931 d.field("enumerated_type", self.as_enumerated_type());
2932 } else if matches!(self.tag, TK_BITMASK) {
2933 d.field("bitmask_type", self.as_bitmask_type());
2934 } else {
2935 d.field("extended_type", self.as_extended_type());
2936 }
2937 d.finish()
2938 }
2939 }
2940 impl PartialEq for CompleteTypeObject {
2941 #[allow(unreachable_patterns)]
2942 fn eq(&self, other: &Self) -> bool {
2943 if self.tag != other.tag {
2944 return false;
2945 }
2946 if matches!(self.tag, TK_ALIAS) {
2947 self.as_alias_type() == other.as_alias_type()
2948 } else if matches!(self.tag, TK_ANNOTATION) {
2949 self.as_annotation_type() == other.as_annotation_type()
2950 } else if matches!(self.tag, TK_STRUCTURE) {
2951 self.as_struct_type() == other.as_struct_type()
2952 } else if matches!(self.tag, TK_UNION) {
2953 self.as_union_type() == other.as_union_type()
2954 } else if matches!(self.tag, TK_BITSET) {
2955 self.as_bitset_type() == other.as_bitset_type()
2956 } else if matches!(self.tag, TK_SEQUENCE) {
2957 self.as_sequence_type() == other.as_sequence_type()
2958 } else if matches!(self.tag, TK_ARRAY) {
2959 self.as_array_type() == other.as_array_type()
2960 } else if matches!(self.tag, TK_MAP) {
2961 self.as_map_type() == other.as_map_type()
2962 } else if matches!(self.tag, TK_ENUM) {
2963 self.as_enumerated_type() == other.as_enumerated_type()
2964 } else if matches!(self.tag, TK_BITMASK) {
2965 self.as_bitmask_type() == other.as_bitmask_type()
2966 } else {
2967 self.as_extended_type() == other.as_extended_type()
2968 }
2969 }
2970 }
2971 impl CompleteTypeObject {
2972 pub fn new_alias_type(value: CompleteAliasType) -> Self {
2973 Self {
2974 tag: TK_ALIAS,
2975 data: CompleteTypeObjectData {
2976 alias_type: core::mem::ManuallyDrop::new(value),
2977 },
2978 }
2979 }
2980 pub fn is_alias_type(&self) -> bool {
2981 matches!(self.tag, TK_ALIAS)
2982 }
2983 #[allow(clippy::borrowed_box)]
2984 pub fn as_alias_type(&self) -> &CompleteAliasType {
2985 debug_assert!(self.is_alias_type());
2986 unsafe { &self.data.alias_type }
2987 }
2988 #[allow(clippy::borrowed_box)]
2989 pub fn as_alias_type_mut(&mut self) -> &mut CompleteAliasType {
2990 debug_assert!(self.is_alias_type());
2991 unsafe { &mut self.data.alias_type }
2992 }
2993 pub fn into_alias_type(self) -> CompleteAliasType {
2994 debug_assert!(self.is_alias_type());
2995 unsafe {
2996 let mut forget = core::mem::ManuallyDrop::new(self);
2997 core::mem::ManuallyDrop::take(&mut forget.data.alias_type)
2998 }
2999 }
3000 pub fn new_annotation_type(value: CompleteAnnotationType) -> Self {
3001 Self {
3002 tag: TK_ANNOTATION,
3003 data: CompleteTypeObjectData {
3004 annotation_type: core::mem::ManuallyDrop::new(value),
3005 },
3006 }
3007 }
3008 pub fn is_annotation_type(&self) -> bool {
3009 matches!(self.tag, TK_ANNOTATION)
3010 }
3011 #[allow(clippy::borrowed_box)]
3012 pub fn as_annotation_type(&self) -> &CompleteAnnotationType {
3013 debug_assert!(self.is_annotation_type());
3014 unsafe { &self.data.annotation_type }
3015 }
3016 #[allow(clippy::borrowed_box)]
3017 pub fn as_annotation_type_mut(&mut self) -> &mut CompleteAnnotationType {
3018 debug_assert!(self.is_annotation_type());
3019 unsafe { &mut self.data.annotation_type }
3020 }
3021 pub fn into_annotation_type(self) -> CompleteAnnotationType {
3022 debug_assert!(self.is_annotation_type());
3023 unsafe {
3024 let mut forget = core::mem::ManuallyDrop::new(self);
3025 core::mem::ManuallyDrop::take(&mut forget.data.annotation_type)
3026 }
3027 }
3028 pub fn new_struct_type(value: CompleteStructType) -> Self {
3029 Self {
3030 tag: TK_STRUCTURE,
3031 data: CompleteTypeObjectData {
3032 struct_type: core::mem::ManuallyDrop::new(value),
3033 },
3034 }
3035 }
3036 pub fn is_struct_type(&self) -> bool {
3037 matches!(self.tag, TK_STRUCTURE)
3038 }
3039 #[allow(clippy::borrowed_box)]
3040 pub fn as_struct_type(&self) -> &CompleteStructType {
3041 debug_assert!(self.is_struct_type());
3042 unsafe { &self.data.struct_type }
3043 }
3044 #[allow(clippy::borrowed_box)]
3045 pub fn as_struct_type_mut(&mut self) -> &mut CompleteStructType {
3046 debug_assert!(self.is_struct_type());
3047 unsafe { &mut self.data.struct_type }
3048 }
3049 pub fn into_struct_type(self) -> CompleteStructType {
3050 debug_assert!(self.is_struct_type());
3051 unsafe {
3052 let mut forget = core::mem::ManuallyDrop::new(self);
3053 core::mem::ManuallyDrop::take(&mut forget.data.struct_type)
3054 }
3055 }
3056 pub fn new_union_type(value: CompleteUnionType) -> Self {
3057 Self {
3058 tag: TK_UNION,
3059 data: CompleteTypeObjectData {
3060 union_type: core::mem::ManuallyDrop::new(value),
3061 },
3062 }
3063 }
3064 pub fn is_union_type(&self) -> bool {
3065 matches!(self.tag, TK_UNION)
3066 }
3067 #[allow(clippy::borrowed_box)]
3068 pub fn as_union_type(&self) -> &CompleteUnionType {
3069 debug_assert!(self.is_union_type());
3070 unsafe { &self.data.union_type }
3071 }
3072 #[allow(clippy::borrowed_box)]
3073 pub fn as_union_type_mut(&mut self) -> &mut CompleteUnionType {
3074 debug_assert!(self.is_union_type());
3075 unsafe { &mut self.data.union_type }
3076 }
3077 pub fn into_union_type(self) -> CompleteUnionType {
3078 debug_assert!(self.is_union_type());
3079 unsafe {
3080 let mut forget = core::mem::ManuallyDrop::new(self);
3081 core::mem::ManuallyDrop::take(&mut forget.data.union_type)
3082 }
3083 }
3084 pub fn new_bitset_type(value: CompleteBitsetType) -> Self {
3085 Self {
3086 tag: TK_BITSET,
3087 data: CompleteTypeObjectData {
3088 bitset_type: core::mem::ManuallyDrop::new(value),
3089 },
3090 }
3091 }
3092 pub fn is_bitset_type(&self) -> bool {
3093 matches!(self.tag, TK_BITSET)
3094 }
3095 #[allow(clippy::borrowed_box)]
3096 pub fn as_bitset_type(&self) -> &CompleteBitsetType {
3097 debug_assert!(self.is_bitset_type());
3098 unsafe { &self.data.bitset_type }
3099 }
3100 #[allow(clippy::borrowed_box)]
3101 pub fn as_bitset_type_mut(&mut self) -> &mut CompleteBitsetType {
3102 debug_assert!(self.is_bitset_type());
3103 unsafe { &mut self.data.bitset_type }
3104 }
3105 pub fn into_bitset_type(self) -> CompleteBitsetType {
3106 debug_assert!(self.is_bitset_type());
3107 unsafe {
3108 let mut forget = core::mem::ManuallyDrop::new(self);
3109 core::mem::ManuallyDrop::take(&mut forget.data.bitset_type)
3110 }
3111 }
3112 pub fn new_sequence_type(value: CompleteSequenceType) -> Self {
3113 Self {
3114 tag: TK_SEQUENCE,
3115 data: CompleteTypeObjectData {
3116 sequence_type: core::mem::ManuallyDrop::new(value),
3117 },
3118 }
3119 }
3120 pub fn is_sequence_type(&self) -> bool {
3121 matches!(self.tag, TK_SEQUENCE)
3122 }
3123 #[allow(clippy::borrowed_box)]
3124 pub fn as_sequence_type(&self) -> &CompleteSequenceType {
3125 debug_assert!(self.is_sequence_type());
3126 unsafe { &self.data.sequence_type }
3127 }
3128 #[allow(clippy::borrowed_box)]
3129 pub fn as_sequence_type_mut(&mut self) -> &mut CompleteSequenceType {
3130 debug_assert!(self.is_sequence_type());
3131 unsafe { &mut self.data.sequence_type }
3132 }
3133 pub fn into_sequence_type(self) -> CompleteSequenceType {
3134 debug_assert!(self.is_sequence_type());
3135 unsafe {
3136 let mut forget = core::mem::ManuallyDrop::new(self);
3137 core::mem::ManuallyDrop::take(&mut forget.data.sequence_type)
3138 }
3139 }
3140 pub fn new_array_type(value: CompleteArrayType) -> Self {
3141 Self {
3142 tag: TK_ARRAY,
3143 data: CompleteTypeObjectData {
3144 array_type: core::mem::ManuallyDrop::new(value),
3145 },
3146 }
3147 }
3148 pub fn is_array_type(&self) -> bool {
3149 matches!(self.tag, TK_ARRAY)
3150 }
3151 #[allow(clippy::borrowed_box)]
3152 pub fn as_array_type(&self) -> &CompleteArrayType {
3153 debug_assert!(self.is_array_type());
3154 unsafe { &self.data.array_type }
3155 }
3156 #[allow(clippy::borrowed_box)]
3157 pub fn as_array_type_mut(&mut self) -> &mut CompleteArrayType {
3158 debug_assert!(self.is_array_type());
3159 unsafe { &mut self.data.array_type }
3160 }
3161 pub fn into_array_type(self) -> CompleteArrayType {
3162 debug_assert!(self.is_array_type());
3163 unsafe {
3164 let mut forget = core::mem::ManuallyDrop::new(self);
3165 core::mem::ManuallyDrop::take(&mut forget.data.array_type)
3166 }
3167 }
3168 pub fn new_map_type(value: CompleteMapType) -> Self {
3169 Self {
3170 tag: TK_MAP,
3171 data: CompleteTypeObjectData {
3172 map_type: core::mem::ManuallyDrop::new(value),
3173 },
3174 }
3175 }
3176 pub fn is_map_type(&self) -> bool {
3177 matches!(self.tag, TK_MAP)
3178 }
3179 #[allow(clippy::borrowed_box)]
3180 pub fn as_map_type(&self) -> &CompleteMapType {
3181 debug_assert!(self.is_map_type());
3182 unsafe { &self.data.map_type }
3183 }
3184 #[allow(clippy::borrowed_box)]
3185 pub fn as_map_type_mut(&mut self) -> &mut CompleteMapType {
3186 debug_assert!(self.is_map_type());
3187 unsafe { &mut self.data.map_type }
3188 }
3189 pub fn into_map_type(self) -> CompleteMapType {
3190 debug_assert!(self.is_map_type());
3191 unsafe {
3192 let mut forget = core::mem::ManuallyDrop::new(self);
3193 core::mem::ManuallyDrop::take(&mut forget.data.map_type)
3194 }
3195 }
3196 pub fn new_enumerated_type(value: CompleteEnumeratedType) -> Self {
3197 Self {
3198 tag: TK_ENUM,
3199 data: CompleteTypeObjectData {
3200 enumerated_type: core::mem::ManuallyDrop::new(value),
3201 },
3202 }
3203 }
3204 pub fn is_enumerated_type(&self) -> bool {
3205 matches!(self.tag, TK_ENUM)
3206 }
3207 #[allow(clippy::borrowed_box)]
3208 pub fn as_enumerated_type(&self) -> &CompleteEnumeratedType {
3209 debug_assert!(self.is_enumerated_type());
3210 unsafe { &self.data.enumerated_type }
3211 }
3212 #[allow(clippy::borrowed_box)]
3213 pub fn as_enumerated_type_mut(&mut self) -> &mut CompleteEnumeratedType {
3214 debug_assert!(self.is_enumerated_type());
3215 unsafe { &mut self.data.enumerated_type }
3216 }
3217 pub fn into_enumerated_type(self) -> CompleteEnumeratedType {
3218 debug_assert!(self.is_enumerated_type());
3219 unsafe {
3220 let mut forget = core::mem::ManuallyDrop::new(self);
3221 core::mem::ManuallyDrop::take(&mut forget.data.enumerated_type)
3222 }
3223 }
3224 pub fn new_bitmask_type(value: CompleteBitmaskType) -> Self {
3225 Self {
3226 tag: TK_BITMASK,
3227 data: CompleteTypeObjectData {
3228 bitmask_type: core::mem::ManuallyDrop::new(value),
3229 },
3230 }
3231 }
3232 pub fn is_bitmask_type(&self) -> bool {
3233 matches!(self.tag, TK_BITMASK)
3234 }
3235 #[allow(clippy::borrowed_box)]
3236 pub fn as_bitmask_type(&self) -> &CompleteBitmaskType {
3237 debug_assert!(self.is_bitmask_type());
3238 unsafe { &self.data.bitmask_type }
3239 }
3240 #[allow(clippy::borrowed_box)]
3241 pub fn as_bitmask_type_mut(&mut self) -> &mut CompleteBitmaskType {
3242 debug_assert!(self.is_bitmask_type());
3243 unsafe { &mut self.data.bitmask_type }
3244 }
3245 pub fn into_bitmask_type(self) -> CompleteBitmaskType {
3246 debug_assert!(self.is_bitmask_type());
3247 unsafe {
3248 let mut forget = core::mem::ManuallyDrop::new(self);
3249 core::mem::ManuallyDrop::take(&mut forget.data.bitmask_type)
3250 }
3251 }
3252 pub fn new_extended_type(value: CompleteExtendedType) -> Self {
3253 Self {
3254 tag: u8::default(),
3255 data: CompleteTypeObjectData {
3256 extended_type: core::mem::ManuallyDrop::new(value),
3257 },
3258 }
3259 }
3260 pub fn is_extended_type(&self) -> bool {
3261 matches!(self.tag, _)
3262 }
3263 #[allow(clippy::borrowed_box)]
3264 pub fn as_extended_type(&self) -> &CompleteExtendedType {
3265 debug_assert!(self.is_extended_type());
3266 unsafe { &self.data.extended_type }
3267 }
3268 #[allow(clippy::borrowed_box)]
3269 pub fn as_extended_type_mut(&mut self) -> &mut CompleteExtendedType {
3270 debug_assert!(self.is_extended_type());
3271 unsafe { &mut self.data.extended_type }
3272 }
3273 pub fn into_extended_type(self) -> CompleteExtendedType {
3274 debug_assert!(self.is_extended_type());
3275 unsafe {
3276 let mut forget = core::mem::ManuallyDrop::new(self);
3277 core::mem::ManuallyDrop::take(&mut forget.data.extended_type)
3278 }
3279 }
3280 pub fn tag(&self) -> &u8 {
3281 &self.tag
3282 }
3283 }
3284 impl Default for CompleteTypeObject {
3285 fn default() -> Self {
3286 Self {
3287 tag: u8::default(),
3288 data: CompleteTypeObjectData {
3289 extended_type: core::mem::ManuallyDrop::new(CompleteExtendedType::default()),
3290 },
3291 }
3292 }
3293 }
3294 #[derive(::serde::Serialize)]
3295 struct CompleteTypeObjectSerdeRef<'__a> {
3296 tag: &'__a str,
3297 data: CompleteTypeObjectSerdeRefData<'__a>,
3298 }
3299 #[allow(clippy::borrowed_box)]
3300 #[derive(::serde::Serialize)]
3301 #[serde(untagged)]
3302 enum CompleteTypeObjectSerdeRefData<'__a> {
3303 Case0(&'__a CompleteAliasType),
3304 Case1(&'__a CompleteAnnotationType),
3305 Case2(&'__a CompleteStructType),
3306 Case3(&'__a CompleteUnionType),
3307 Case4(&'__a CompleteBitsetType),
3308 Case5(&'__a CompleteSequenceType),
3309 Case6(&'__a CompleteArrayType),
3310 Case7(&'__a CompleteMapType),
3311 Case8(&'__a CompleteEnumeratedType),
3312 Case9(&'__a CompleteBitmaskType),
3313 Case10(&'__a CompleteExtendedType),
3314 }
3315 impl serde::Serialize for CompleteTypeObject {
3316 #[allow(unreachable_patterns)]
3317 fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
3318 where
3319 __S: serde::Serializer,
3320 {
3321 let helper = if matches!(self.tag, TK_ALIAS) {
3322 let tag = "TK_ALIAS";
3323 CompleteTypeObjectSerdeRef {
3324 tag,
3325 data: CompleteTypeObjectSerdeRefData::Case0(self.as_alias_type()),
3326 }
3327 } else if matches!(self.tag, TK_ANNOTATION) {
3328 let tag = "TK_ANNOTATION";
3329 CompleteTypeObjectSerdeRef {
3330 tag,
3331 data: CompleteTypeObjectSerdeRefData::Case1(self.as_annotation_type()),
3332 }
3333 } else if matches!(self.tag, TK_STRUCTURE) {
3334 let tag = "TK_STRUCTURE";
3335 CompleteTypeObjectSerdeRef {
3336 tag,
3337 data: CompleteTypeObjectSerdeRefData::Case2(self.as_struct_type()),
3338 }
3339 } else if matches!(self.tag, TK_UNION) {
3340 let tag = "TK_UNION";
3341 CompleteTypeObjectSerdeRef {
3342 tag,
3343 data: CompleteTypeObjectSerdeRefData::Case3(self.as_union_type()),
3344 }
3345 } else if matches!(self.tag, TK_BITSET) {
3346 let tag = "TK_BITSET";
3347 CompleteTypeObjectSerdeRef {
3348 tag,
3349 data: CompleteTypeObjectSerdeRefData::Case4(self.as_bitset_type()),
3350 }
3351 } else if matches!(self.tag, TK_SEQUENCE) {
3352 let tag = "TK_SEQUENCE";
3353 CompleteTypeObjectSerdeRef {
3354 tag,
3355 data: CompleteTypeObjectSerdeRefData::Case5(self.as_sequence_type()),
3356 }
3357 } else if matches!(self.tag, TK_ARRAY) {
3358 let tag = "TK_ARRAY";
3359 CompleteTypeObjectSerdeRef {
3360 tag,
3361 data: CompleteTypeObjectSerdeRefData::Case6(self.as_array_type()),
3362 }
3363 } else if matches!(self.tag, TK_MAP) {
3364 let tag = "TK_MAP";
3365 CompleteTypeObjectSerdeRef {
3366 tag,
3367 data: CompleteTypeObjectSerdeRefData::Case7(self.as_map_type()),
3368 }
3369 } else if matches!(self.tag, TK_ENUM) {
3370 let tag = "TK_ENUM";
3371 CompleteTypeObjectSerdeRef {
3372 tag,
3373 data: CompleteTypeObjectSerdeRefData::Case8(self.as_enumerated_type()),
3374 }
3375 } else if matches!(self.tag, TK_BITMASK) {
3376 let tag = "TK_BITMASK";
3377 CompleteTypeObjectSerdeRef {
3378 tag,
3379 data: CompleteTypeObjectSerdeRefData::Case9(self.as_bitmask_type()),
3380 }
3381 } else {
3382 let tag = "default";
3383 CompleteTypeObjectSerdeRef {
3384 tag,
3385 data: CompleteTypeObjectSerdeRefData::Case10(self.as_extended_type()),
3386 }
3387 };
3388 helper.serialize(__serializer)
3389 }
3390 }
3391 #[derive(::serde::Deserialize)]
3392 struct CompleteTypeObjectSerdeOwned {
3393 tag: String,
3394 data: ::serde_json::Value,
3395 }
3396 impl<'de> serde::Deserialize<'de> for CompleteTypeObject {
3397 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
3398 where
3399 D: serde::Deserializer<'de>,
3400 {
3401 let helper = CompleteTypeObjectSerdeOwned::deserialize(deserializer)?;
3402 match helper.tag.as_str() {
3403 "TK_ALIAS" => {
3404 let value = ::serde_json::from_value::<
3405 CompleteAliasType,
3406 >(helper.data)
3407 .map_err(|err| serde::de::Error::custom(
3408 format!(
3409 "union CompleteTypeObject payload decode failed for tag `TK_ALIAS`: {err}"
3410 ),
3411 ))?;
3412 Ok(Self {
3413 tag: TK_ALIAS,
3414 data: CompleteTypeObjectData {
3415 alias_type: core::mem::ManuallyDrop::new(value),
3416 },
3417 })
3418 }
3419 "TK_ANNOTATION" => {
3420 let value = ::serde_json::from_value::<
3421 CompleteAnnotationType,
3422 >(helper.data)
3423 .map_err(|err| serde::de::Error::custom(
3424 format!(
3425 "union CompleteTypeObject payload decode failed for tag `TK_ANNOTATION`: {err}"
3426 ),
3427 ))?;
3428 Ok(Self {
3429 tag: TK_ANNOTATION,
3430 data: CompleteTypeObjectData {
3431 annotation_type: core::mem::ManuallyDrop::new(value),
3432 },
3433 })
3434 }
3435 "TK_STRUCTURE" => {
3436 let value = ::serde_json::from_value::<
3437 CompleteStructType,
3438 >(helper.data)
3439 .map_err(|err| serde::de::Error::custom(
3440 format!(
3441 "union CompleteTypeObject payload decode failed for tag `TK_STRUCTURE`: {err}"
3442 ),
3443 ))?;
3444 Ok(Self {
3445 tag: TK_STRUCTURE,
3446 data: CompleteTypeObjectData {
3447 struct_type: core::mem::ManuallyDrop::new(value),
3448 },
3449 })
3450 }
3451 "TK_UNION" => {
3452 let value = ::serde_json::from_value::<
3453 CompleteUnionType,
3454 >(helper.data)
3455 .map_err(|err| serde::de::Error::custom(
3456 format!(
3457 "union CompleteTypeObject payload decode failed for tag `TK_UNION`: {err}"
3458 ),
3459 ))?;
3460 Ok(Self {
3461 tag: TK_UNION,
3462 data: CompleteTypeObjectData {
3463 union_type: core::mem::ManuallyDrop::new(value),
3464 },
3465 })
3466 }
3467 "TK_BITSET" => {
3468 let value = ::serde_json::from_value::<
3469 CompleteBitsetType,
3470 >(helper.data)
3471 .map_err(|err| serde::de::Error::custom(
3472 format!(
3473 "union CompleteTypeObject payload decode failed for tag `TK_BITSET`: {err}"
3474 ),
3475 ))?;
3476 Ok(Self {
3477 tag: TK_BITSET,
3478 data: CompleteTypeObjectData {
3479 bitset_type: core::mem::ManuallyDrop::new(value),
3480 },
3481 })
3482 }
3483 "TK_SEQUENCE" => {
3484 let value = ::serde_json::from_value::<
3485 CompleteSequenceType,
3486 >(helper.data)
3487 .map_err(|err| serde::de::Error::custom(
3488 format!(
3489 "union CompleteTypeObject payload decode failed for tag `TK_SEQUENCE`: {err}"
3490 ),
3491 ))?;
3492 Ok(Self {
3493 tag: TK_SEQUENCE,
3494 data: CompleteTypeObjectData {
3495 sequence_type: core::mem::ManuallyDrop::new(value),
3496 },
3497 })
3498 }
3499 "TK_ARRAY" => {
3500 let value = ::serde_json::from_value::<
3501 CompleteArrayType,
3502 >(helper.data)
3503 .map_err(|err| serde::de::Error::custom(
3504 format!(
3505 "union CompleteTypeObject payload decode failed for tag `TK_ARRAY`: {err}"
3506 ),
3507 ))?;
3508 Ok(Self {
3509 tag: TK_ARRAY,
3510 data: CompleteTypeObjectData {
3511 array_type: core::mem::ManuallyDrop::new(value),
3512 },
3513 })
3514 }
3515 "TK_MAP" => {
3516 let value = ::serde_json::from_value::<
3517 CompleteMapType,
3518 >(helper.data)
3519 .map_err(|err| serde::de::Error::custom(
3520 format!(
3521 "union CompleteTypeObject payload decode failed for tag `TK_MAP`: {err}"
3522 ),
3523 ))?;
3524 Ok(Self {
3525 tag: TK_MAP,
3526 data: CompleteTypeObjectData {
3527 map_type: core::mem::ManuallyDrop::new(value),
3528 },
3529 })
3530 }
3531 "TK_ENUM" => {
3532 let value = ::serde_json::from_value::<
3533 CompleteEnumeratedType,
3534 >(helper.data)
3535 .map_err(|err| serde::de::Error::custom(
3536 format!(
3537 "union CompleteTypeObject payload decode failed for tag `TK_ENUM`: {err}"
3538 ),
3539 ))?;
3540 Ok(Self {
3541 tag: TK_ENUM,
3542 data: CompleteTypeObjectData {
3543 enumerated_type: core::mem::ManuallyDrop::new(value),
3544 },
3545 })
3546 }
3547 "TK_BITMASK" => {
3548 let value = ::serde_json::from_value::<
3549 CompleteBitmaskType,
3550 >(helper.data)
3551 .map_err(|err| serde::de::Error::custom(
3552 format!(
3553 "union CompleteTypeObject payload decode failed for tag `TK_BITMASK`: {err}"
3554 ),
3555 ))?;
3556 Ok(Self {
3557 tag: TK_BITMASK,
3558 data: CompleteTypeObjectData {
3559 bitmask_type: core::mem::ManuallyDrop::new(value),
3560 },
3561 })
3562 }
3563 "default" => {
3564 let value = ::serde_json::from_value::<
3565 CompleteExtendedType,
3566 >(helper.data)
3567 .map_err(|err| serde::de::Error::custom(
3568 format!(
3569 "union CompleteTypeObject payload decode failed for tag `default`: {err}"
3570 ),
3571 ))?;
3572 Ok(Self {
3573 tag: u8::default(),
3574 data: CompleteTypeObjectData {
3575 extended_type: core::mem::ManuallyDrop::new(value),
3576 },
3577 })
3578 }
3579 _ => Err(serde::de::Error::custom(format!(
3580 "union CompleteTypeObject tag/data mismatch for tag `{}`",
3581 helper.tag
3582 ))),
3583 }
3584 }
3585 }
3586 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
3587 pub struct MinimalExtendedType {}
3588 impl MinimalExtendedType {}
3589 pub struct MinimalTypeObject {
3590 tag: u8,
3591 data: MinimalTypeObjectData,
3592 }
3593 union MinimalTypeObjectData {
3594 alias_type: core::mem::ManuallyDrop<MinimalAliasType>,
3595 annotation_type: core::mem::ManuallyDrop<MinimalAnnotationType>,
3596 struct_type: core::mem::ManuallyDrop<MinimalStructType>,
3597 union_type: core::mem::ManuallyDrop<MinimalUnionType>,
3598 bitset_type: core::mem::ManuallyDrop<MinimalBitsetType>,
3599 sequence_type: core::mem::ManuallyDrop<MinimalSequenceType>,
3600 array_type: core::mem::ManuallyDrop<MinimalArrayType>,
3601 map_type: core::mem::ManuallyDrop<MinimalMapType>,
3602 enumerated_type: core::mem::ManuallyDrop<MinimalEnumeratedType>,
3603 bitmask_type: core::mem::ManuallyDrop<MinimalBitmaskType>,
3604 extended_type: core::mem::ManuallyDrop<MinimalExtendedType>,
3605 }
3606 impl Drop for MinimalTypeObject {
3607 #[allow(unreachable_patterns)]
3608 fn drop(&mut self) {
3609 if matches!(self.tag, TK_ALIAS) {
3610 unsafe {
3611 core::mem::ManuallyDrop::drop(&mut self.data.alias_type);
3612 }
3613 } else if matches!(self.tag, TK_ANNOTATION) {
3614 unsafe {
3615 core::mem::ManuallyDrop::drop(&mut self.data.annotation_type);
3616 }
3617 } else if matches!(self.tag, TK_STRUCTURE) {
3618 unsafe {
3619 core::mem::ManuallyDrop::drop(&mut self.data.struct_type);
3620 }
3621 } else if matches!(self.tag, TK_UNION) {
3622 unsafe {
3623 core::mem::ManuallyDrop::drop(&mut self.data.union_type);
3624 }
3625 } else if matches!(self.tag, TK_BITSET) {
3626 unsafe {
3627 core::mem::ManuallyDrop::drop(&mut self.data.bitset_type);
3628 }
3629 } else if matches!(self.tag, TK_SEQUENCE) {
3630 unsafe {
3631 core::mem::ManuallyDrop::drop(&mut self.data.sequence_type);
3632 }
3633 } else if matches!(self.tag, TK_ARRAY) {
3634 unsafe {
3635 core::mem::ManuallyDrop::drop(&mut self.data.array_type);
3636 }
3637 } else if matches!(self.tag, TK_MAP) {
3638 unsafe {
3639 core::mem::ManuallyDrop::drop(&mut self.data.map_type);
3640 }
3641 } else if matches!(self.tag, TK_ENUM) {
3642 unsafe {
3643 core::mem::ManuallyDrop::drop(&mut self.data.enumerated_type);
3644 }
3645 } else if matches!(self.tag, TK_BITMASK) {
3646 unsafe {
3647 core::mem::ManuallyDrop::drop(&mut self.data.bitmask_type);
3648 }
3649 } else {
3650 unsafe {
3651 core::mem::ManuallyDrop::drop(&mut self.data.extended_type);
3652 }
3653 }
3654 }
3655 }
3656 impl Clone for MinimalTypeObject {
3657 #[allow(clippy::clone_on_copy)]
3658 #[allow(unreachable_patterns)]
3659 fn clone(&self) -> Self {
3660 if matches!(self.tag, TK_ALIAS) {
3661 Self::new_alias_type(self.as_alias_type().clone())
3662 } else if matches!(self.tag, TK_ANNOTATION) {
3663 Self::new_annotation_type(self.as_annotation_type().clone())
3664 } else if matches!(self.tag, TK_STRUCTURE) {
3665 Self::new_struct_type(self.as_struct_type().clone())
3666 } else if matches!(self.tag, TK_UNION) {
3667 Self::new_union_type(self.as_union_type().clone())
3668 } else if matches!(self.tag, TK_BITSET) {
3669 Self::new_bitset_type(self.as_bitset_type().clone())
3670 } else if matches!(self.tag, TK_SEQUENCE) {
3671 Self::new_sequence_type(self.as_sequence_type().clone())
3672 } else if matches!(self.tag, TK_ARRAY) {
3673 Self::new_array_type(self.as_array_type().clone())
3674 } else if matches!(self.tag, TK_MAP) {
3675 Self::new_map_type(self.as_map_type().clone())
3676 } else if matches!(self.tag, TK_ENUM) {
3677 Self::new_enumerated_type(self.as_enumerated_type().clone())
3678 } else if matches!(self.tag, TK_BITMASK) {
3679 Self::new_bitmask_type(self.as_bitmask_type().clone())
3680 } else {
3681 Self::new_extended_type(self.as_extended_type().clone())
3682 }
3683 }
3684 }
3685 impl core::fmt::Debug for MinimalTypeObject {
3686 #[allow(unreachable_patterns)]
3687 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
3688 let mut d = f.debug_struct("MinimalTypeObject");
3689 d.field("tag", &self.tag);
3690 if matches!(self.tag, TK_ALIAS) {
3691 d.field("alias_type", self.as_alias_type());
3692 } else if matches!(self.tag, TK_ANNOTATION) {
3693 d.field("annotation_type", self.as_annotation_type());
3694 } else if matches!(self.tag, TK_STRUCTURE) {
3695 d.field("struct_type", self.as_struct_type());
3696 } else if matches!(self.tag, TK_UNION) {
3697 d.field("union_type", self.as_union_type());
3698 } else if matches!(self.tag, TK_BITSET) {
3699 d.field("bitset_type", self.as_bitset_type());
3700 } else if matches!(self.tag, TK_SEQUENCE) {
3701 d.field("sequence_type", self.as_sequence_type());
3702 } else if matches!(self.tag, TK_ARRAY) {
3703 d.field("array_type", self.as_array_type());
3704 } else if matches!(self.tag, TK_MAP) {
3705 d.field("map_type", self.as_map_type());
3706 } else if matches!(self.tag, TK_ENUM) {
3707 d.field("enumerated_type", self.as_enumerated_type());
3708 } else if matches!(self.tag, TK_BITMASK) {
3709 d.field("bitmask_type", self.as_bitmask_type());
3710 } else {
3711 d.field("extended_type", self.as_extended_type());
3712 }
3713 d.finish()
3714 }
3715 }
3716 impl PartialEq for MinimalTypeObject {
3717 #[allow(unreachable_patterns)]
3718 fn eq(&self, other: &Self) -> bool {
3719 if self.tag != other.tag {
3720 return false;
3721 }
3722 if matches!(self.tag, TK_ALIAS) {
3723 self.as_alias_type() == other.as_alias_type()
3724 } else if matches!(self.tag, TK_ANNOTATION) {
3725 self.as_annotation_type() == other.as_annotation_type()
3726 } else if matches!(self.tag, TK_STRUCTURE) {
3727 self.as_struct_type() == other.as_struct_type()
3728 } else if matches!(self.tag, TK_UNION) {
3729 self.as_union_type() == other.as_union_type()
3730 } else if matches!(self.tag, TK_BITSET) {
3731 self.as_bitset_type() == other.as_bitset_type()
3732 } else if matches!(self.tag, TK_SEQUENCE) {
3733 self.as_sequence_type() == other.as_sequence_type()
3734 } else if matches!(self.tag, TK_ARRAY) {
3735 self.as_array_type() == other.as_array_type()
3736 } else if matches!(self.tag, TK_MAP) {
3737 self.as_map_type() == other.as_map_type()
3738 } else if matches!(self.tag, TK_ENUM) {
3739 self.as_enumerated_type() == other.as_enumerated_type()
3740 } else if matches!(self.tag, TK_BITMASK) {
3741 self.as_bitmask_type() == other.as_bitmask_type()
3742 } else {
3743 self.as_extended_type() == other.as_extended_type()
3744 }
3745 }
3746 }
3747 impl MinimalTypeObject {
3748 pub fn new_alias_type(value: MinimalAliasType) -> Self {
3749 Self {
3750 tag: TK_ALIAS,
3751 data: MinimalTypeObjectData {
3752 alias_type: core::mem::ManuallyDrop::new(value),
3753 },
3754 }
3755 }
3756 pub fn is_alias_type(&self) -> bool {
3757 matches!(self.tag, TK_ALIAS)
3758 }
3759 #[allow(clippy::borrowed_box)]
3760 pub fn as_alias_type(&self) -> &MinimalAliasType {
3761 debug_assert!(self.is_alias_type());
3762 unsafe { &self.data.alias_type }
3763 }
3764 #[allow(clippy::borrowed_box)]
3765 pub fn as_alias_type_mut(&mut self) -> &mut MinimalAliasType {
3766 debug_assert!(self.is_alias_type());
3767 unsafe { &mut self.data.alias_type }
3768 }
3769 pub fn into_alias_type(self) -> MinimalAliasType {
3770 debug_assert!(self.is_alias_type());
3771 unsafe {
3772 let mut forget = core::mem::ManuallyDrop::new(self);
3773 core::mem::ManuallyDrop::take(&mut forget.data.alias_type)
3774 }
3775 }
3776 pub fn new_annotation_type(value: MinimalAnnotationType) -> Self {
3777 Self {
3778 tag: TK_ANNOTATION,
3779 data: MinimalTypeObjectData {
3780 annotation_type: core::mem::ManuallyDrop::new(value),
3781 },
3782 }
3783 }
3784 pub fn is_annotation_type(&self) -> bool {
3785 matches!(self.tag, TK_ANNOTATION)
3786 }
3787 #[allow(clippy::borrowed_box)]
3788 pub fn as_annotation_type(&self) -> &MinimalAnnotationType {
3789 debug_assert!(self.is_annotation_type());
3790 unsafe { &self.data.annotation_type }
3791 }
3792 #[allow(clippy::borrowed_box)]
3793 pub fn as_annotation_type_mut(&mut self) -> &mut MinimalAnnotationType {
3794 debug_assert!(self.is_annotation_type());
3795 unsafe { &mut self.data.annotation_type }
3796 }
3797 pub fn into_annotation_type(self) -> MinimalAnnotationType {
3798 debug_assert!(self.is_annotation_type());
3799 unsafe {
3800 let mut forget = core::mem::ManuallyDrop::new(self);
3801 core::mem::ManuallyDrop::take(&mut forget.data.annotation_type)
3802 }
3803 }
3804 pub fn new_struct_type(value: MinimalStructType) -> Self {
3805 Self {
3806 tag: TK_STRUCTURE,
3807 data: MinimalTypeObjectData {
3808 struct_type: core::mem::ManuallyDrop::new(value),
3809 },
3810 }
3811 }
3812 pub fn is_struct_type(&self) -> bool {
3813 matches!(self.tag, TK_STRUCTURE)
3814 }
3815 #[allow(clippy::borrowed_box)]
3816 pub fn as_struct_type(&self) -> &MinimalStructType {
3817 debug_assert!(self.is_struct_type());
3818 unsafe { &self.data.struct_type }
3819 }
3820 #[allow(clippy::borrowed_box)]
3821 pub fn as_struct_type_mut(&mut self) -> &mut MinimalStructType {
3822 debug_assert!(self.is_struct_type());
3823 unsafe { &mut self.data.struct_type }
3824 }
3825 pub fn into_struct_type(self) -> MinimalStructType {
3826 debug_assert!(self.is_struct_type());
3827 unsafe {
3828 let mut forget = core::mem::ManuallyDrop::new(self);
3829 core::mem::ManuallyDrop::take(&mut forget.data.struct_type)
3830 }
3831 }
3832 pub fn new_union_type(value: MinimalUnionType) -> Self {
3833 Self {
3834 tag: TK_UNION,
3835 data: MinimalTypeObjectData {
3836 union_type: core::mem::ManuallyDrop::new(value),
3837 },
3838 }
3839 }
3840 pub fn is_union_type(&self) -> bool {
3841 matches!(self.tag, TK_UNION)
3842 }
3843 #[allow(clippy::borrowed_box)]
3844 pub fn as_union_type(&self) -> &MinimalUnionType {
3845 debug_assert!(self.is_union_type());
3846 unsafe { &self.data.union_type }
3847 }
3848 #[allow(clippy::borrowed_box)]
3849 pub fn as_union_type_mut(&mut self) -> &mut MinimalUnionType {
3850 debug_assert!(self.is_union_type());
3851 unsafe { &mut self.data.union_type }
3852 }
3853 pub fn into_union_type(self) -> MinimalUnionType {
3854 debug_assert!(self.is_union_type());
3855 unsafe {
3856 let mut forget = core::mem::ManuallyDrop::new(self);
3857 core::mem::ManuallyDrop::take(&mut forget.data.union_type)
3858 }
3859 }
3860 pub fn new_bitset_type(value: MinimalBitsetType) -> Self {
3861 Self {
3862 tag: TK_BITSET,
3863 data: MinimalTypeObjectData {
3864 bitset_type: core::mem::ManuallyDrop::new(value),
3865 },
3866 }
3867 }
3868 pub fn is_bitset_type(&self) -> bool {
3869 matches!(self.tag, TK_BITSET)
3870 }
3871 #[allow(clippy::borrowed_box)]
3872 pub fn as_bitset_type(&self) -> &MinimalBitsetType {
3873 debug_assert!(self.is_bitset_type());
3874 unsafe { &self.data.bitset_type }
3875 }
3876 #[allow(clippy::borrowed_box)]
3877 pub fn as_bitset_type_mut(&mut self) -> &mut MinimalBitsetType {
3878 debug_assert!(self.is_bitset_type());
3879 unsafe { &mut self.data.bitset_type }
3880 }
3881 pub fn into_bitset_type(self) -> MinimalBitsetType {
3882 debug_assert!(self.is_bitset_type());
3883 unsafe {
3884 let mut forget = core::mem::ManuallyDrop::new(self);
3885 core::mem::ManuallyDrop::take(&mut forget.data.bitset_type)
3886 }
3887 }
3888 pub fn new_sequence_type(value: MinimalSequenceType) -> Self {
3889 Self {
3890 tag: TK_SEQUENCE,
3891 data: MinimalTypeObjectData {
3892 sequence_type: core::mem::ManuallyDrop::new(value),
3893 },
3894 }
3895 }
3896 pub fn is_sequence_type(&self) -> bool {
3897 matches!(self.tag, TK_SEQUENCE)
3898 }
3899 #[allow(clippy::borrowed_box)]
3900 pub fn as_sequence_type(&self) -> &MinimalSequenceType {
3901 debug_assert!(self.is_sequence_type());
3902 unsafe { &self.data.sequence_type }
3903 }
3904 #[allow(clippy::borrowed_box)]
3905 pub fn as_sequence_type_mut(&mut self) -> &mut MinimalSequenceType {
3906 debug_assert!(self.is_sequence_type());
3907 unsafe { &mut self.data.sequence_type }
3908 }
3909 pub fn into_sequence_type(self) -> MinimalSequenceType {
3910 debug_assert!(self.is_sequence_type());
3911 unsafe {
3912 let mut forget = core::mem::ManuallyDrop::new(self);
3913 core::mem::ManuallyDrop::take(&mut forget.data.sequence_type)
3914 }
3915 }
3916 pub fn new_array_type(value: MinimalArrayType) -> Self {
3917 Self {
3918 tag: TK_ARRAY,
3919 data: MinimalTypeObjectData {
3920 array_type: core::mem::ManuallyDrop::new(value),
3921 },
3922 }
3923 }
3924 pub fn is_array_type(&self) -> bool {
3925 matches!(self.tag, TK_ARRAY)
3926 }
3927 #[allow(clippy::borrowed_box)]
3928 pub fn as_array_type(&self) -> &MinimalArrayType {
3929 debug_assert!(self.is_array_type());
3930 unsafe { &self.data.array_type }
3931 }
3932 #[allow(clippy::borrowed_box)]
3933 pub fn as_array_type_mut(&mut self) -> &mut MinimalArrayType {
3934 debug_assert!(self.is_array_type());
3935 unsafe { &mut self.data.array_type }
3936 }
3937 pub fn into_array_type(self) -> MinimalArrayType {
3938 debug_assert!(self.is_array_type());
3939 unsafe {
3940 let mut forget = core::mem::ManuallyDrop::new(self);
3941 core::mem::ManuallyDrop::take(&mut forget.data.array_type)
3942 }
3943 }
3944 pub fn new_map_type(value: MinimalMapType) -> Self {
3945 Self {
3946 tag: TK_MAP,
3947 data: MinimalTypeObjectData {
3948 map_type: core::mem::ManuallyDrop::new(value),
3949 },
3950 }
3951 }
3952 pub fn is_map_type(&self) -> bool {
3953 matches!(self.tag, TK_MAP)
3954 }
3955 #[allow(clippy::borrowed_box)]
3956 pub fn as_map_type(&self) -> &MinimalMapType {
3957 debug_assert!(self.is_map_type());
3958 unsafe { &self.data.map_type }
3959 }
3960 #[allow(clippy::borrowed_box)]
3961 pub fn as_map_type_mut(&mut self) -> &mut MinimalMapType {
3962 debug_assert!(self.is_map_type());
3963 unsafe { &mut self.data.map_type }
3964 }
3965 pub fn into_map_type(self) -> MinimalMapType {
3966 debug_assert!(self.is_map_type());
3967 unsafe {
3968 let mut forget = core::mem::ManuallyDrop::new(self);
3969 core::mem::ManuallyDrop::take(&mut forget.data.map_type)
3970 }
3971 }
3972 pub fn new_enumerated_type(value: MinimalEnumeratedType) -> Self {
3973 Self {
3974 tag: TK_ENUM,
3975 data: MinimalTypeObjectData {
3976 enumerated_type: core::mem::ManuallyDrop::new(value),
3977 },
3978 }
3979 }
3980 pub fn is_enumerated_type(&self) -> bool {
3981 matches!(self.tag, TK_ENUM)
3982 }
3983 #[allow(clippy::borrowed_box)]
3984 pub fn as_enumerated_type(&self) -> &MinimalEnumeratedType {
3985 debug_assert!(self.is_enumerated_type());
3986 unsafe { &self.data.enumerated_type }
3987 }
3988 #[allow(clippy::borrowed_box)]
3989 pub fn as_enumerated_type_mut(&mut self) -> &mut MinimalEnumeratedType {
3990 debug_assert!(self.is_enumerated_type());
3991 unsafe { &mut self.data.enumerated_type }
3992 }
3993 pub fn into_enumerated_type(self) -> MinimalEnumeratedType {
3994 debug_assert!(self.is_enumerated_type());
3995 unsafe {
3996 let mut forget = core::mem::ManuallyDrop::new(self);
3997 core::mem::ManuallyDrop::take(&mut forget.data.enumerated_type)
3998 }
3999 }
4000 pub fn new_bitmask_type(value: MinimalBitmaskType) -> Self {
4001 Self {
4002 tag: TK_BITMASK,
4003 data: MinimalTypeObjectData {
4004 bitmask_type: core::mem::ManuallyDrop::new(value),
4005 },
4006 }
4007 }
4008 pub fn is_bitmask_type(&self) -> bool {
4009 matches!(self.tag, TK_BITMASK)
4010 }
4011 #[allow(clippy::borrowed_box)]
4012 pub fn as_bitmask_type(&self) -> &MinimalBitmaskType {
4013 debug_assert!(self.is_bitmask_type());
4014 unsafe { &self.data.bitmask_type }
4015 }
4016 #[allow(clippy::borrowed_box)]
4017 pub fn as_bitmask_type_mut(&mut self) -> &mut MinimalBitmaskType {
4018 debug_assert!(self.is_bitmask_type());
4019 unsafe { &mut self.data.bitmask_type }
4020 }
4021 pub fn into_bitmask_type(self) -> MinimalBitmaskType {
4022 debug_assert!(self.is_bitmask_type());
4023 unsafe {
4024 let mut forget = core::mem::ManuallyDrop::new(self);
4025 core::mem::ManuallyDrop::take(&mut forget.data.bitmask_type)
4026 }
4027 }
4028 pub fn new_extended_type(value: MinimalExtendedType) -> Self {
4029 Self {
4030 tag: u8::default(),
4031 data: MinimalTypeObjectData {
4032 extended_type: core::mem::ManuallyDrop::new(value),
4033 },
4034 }
4035 }
4036 pub fn is_extended_type(&self) -> bool {
4037 matches!(self.tag, _)
4038 }
4039 #[allow(clippy::borrowed_box)]
4040 pub fn as_extended_type(&self) -> &MinimalExtendedType {
4041 debug_assert!(self.is_extended_type());
4042 unsafe { &self.data.extended_type }
4043 }
4044 #[allow(clippy::borrowed_box)]
4045 pub fn as_extended_type_mut(&mut self) -> &mut MinimalExtendedType {
4046 debug_assert!(self.is_extended_type());
4047 unsafe { &mut self.data.extended_type }
4048 }
4049 pub fn into_extended_type(self) -> MinimalExtendedType {
4050 debug_assert!(self.is_extended_type());
4051 unsafe {
4052 let mut forget = core::mem::ManuallyDrop::new(self);
4053 core::mem::ManuallyDrop::take(&mut forget.data.extended_type)
4054 }
4055 }
4056 pub fn tag(&self) -> &u8 {
4057 &self.tag
4058 }
4059 }
4060 impl Default for MinimalTypeObject {
4061 fn default() -> Self {
4062 Self {
4063 tag: u8::default(),
4064 data: MinimalTypeObjectData {
4065 extended_type: core::mem::ManuallyDrop::new(MinimalExtendedType::default()),
4066 },
4067 }
4068 }
4069 }
4070 #[derive(::serde::Serialize)]
4071 struct MinimalTypeObjectSerdeRef<'__a> {
4072 tag: &'__a str,
4073 data: MinimalTypeObjectSerdeRefData<'__a>,
4074 }
4075 #[allow(clippy::borrowed_box)]
4076 #[derive(::serde::Serialize)]
4077 #[serde(untagged)]
4078 enum MinimalTypeObjectSerdeRefData<'__a> {
4079 Case0(&'__a MinimalAliasType),
4080 Case1(&'__a MinimalAnnotationType),
4081 Case2(&'__a MinimalStructType),
4082 Case3(&'__a MinimalUnionType),
4083 Case4(&'__a MinimalBitsetType),
4084 Case5(&'__a MinimalSequenceType),
4085 Case6(&'__a MinimalArrayType),
4086 Case7(&'__a MinimalMapType),
4087 Case8(&'__a MinimalEnumeratedType),
4088 Case9(&'__a MinimalBitmaskType),
4089 Case10(&'__a MinimalExtendedType),
4090 }
4091 impl serde::Serialize for MinimalTypeObject {
4092 #[allow(unreachable_patterns)]
4093 fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
4094 where
4095 __S: serde::Serializer,
4096 {
4097 let helper = if matches!(self.tag, TK_ALIAS) {
4098 let tag = "TK_ALIAS";
4099 MinimalTypeObjectSerdeRef {
4100 tag,
4101 data: MinimalTypeObjectSerdeRefData::Case0(self.as_alias_type()),
4102 }
4103 } else if matches!(self.tag, TK_ANNOTATION) {
4104 let tag = "TK_ANNOTATION";
4105 MinimalTypeObjectSerdeRef {
4106 tag,
4107 data: MinimalTypeObjectSerdeRefData::Case1(self.as_annotation_type()),
4108 }
4109 } else if matches!(self.tag, TK_STRUCTURE) {
4110 let tag = "TK_STRUCTURE";
4111 MinimalTypeObjectSerdeRef {
4112 tag,
4113 data: MinimalTypeObjectSerdeRefData::Case2(self.as_struct_type()),
4114 }
4115 } else if matches!(self.tag, TK_UNION) {
4116 let tag = "TK_UNION";
4117 MinimalTypeObjectSerdeRef {
4118 tag,
4119 data: MinimalTypeObjectSerdeRefData::Case3(self.as_union_type()),
4120 }
4121 } else if matches!(self.tag, TK_BITSET) {
4122 let tag = "TK_BITSET";
4123 MinimalTypeObjectSerdeRef {
4124 tag,
4125 data: MinimalTypeObjectSerdeRefData::Case4(self.as_bitset_type()),
4126 }
4127 } else if matches!(self.tag, TK_SEQUENCE) {
4128 let tag = "TK_SEQUENCE";
4129 MinimalTypeObjectSerdeRef {
4130 tag,
4131 data: MinimalTypeObjectSerdeRefData::Case5(self.as_sequence_type()),
4132 }
4133 } else if matches!(self.tag, TK_ARRAY) {
4134 let tag = "TK_ARRAY";
4135 MinimalTypeObjectSerdeRef {
4136 tag,
4137 data: MinimalTypeObjectSerdeRefData::Case6(self.as_array_type()),
4138 }
4139 } else if matches!(self.tag, TK_MAP) {
4140 let tag = "TK_MAP";
4141 MinimalTypeObjectSerdeRef {
4142 tag,
4143 data: MinimalTypeObjectSerdeRefData::Case7(self.as_map_type()),
4144 }
4145 } else if matches!(self.tag, TK_ENUM) {
4146 let tag = "TK_ENUM";
4147 MinimalTypeObjectSerdeRef {
4148 tag,
4149 data: MinimalTypeObjectSerdeRefData::Case8(self.as_enumerated_type()),
4150 }
4151 } else if matches!(self.tag, TK_BITMASK) {
4152 let tag = "TK_BITMASK";
4153 MinimalTypeObjectSerdeRef {
4154 tag,
4155 data: MinimalTypeObjectSerdeRefData::Case9(self.as_bitmask_type()),
4156 }
4157 } else {
4158 let tag = "default";
4159 MinimalTypeObjectSerdeRef {
4160 tag,
4161 data: MinimalTypeObjectSerdeRefData::Case10(self.as_extended_type()),
4162 }
4163 };
4164 helper.serialize(__serializer)
4165 }
4166 }
4167 #[derive(::serde::Deserialize)]
4168 struct MinimalTypeObjectSerdeOwned {
4169 tag: String,
4170 data: ::serde_json::Value,
4171 }
4172 impl<'de> serde::Deserialize<'de> for MinimalTypeObject {
4173 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
4174 where
4175 D: serde::Deserializer<'de>,
4176 {
4177 let helper = MinimalTypeObjectSerdeOwned::deserialize(deserializer)?;
4178 match helper.tag.as_str() {
4179 "TK_ALIAS" => {
4180 let value = ::serde_json::from_value::<
4181 MinimalAliasType,
4182 >(helper.data)
4183 .map_err(|err| serde::de::Error::custom(
4184 format!(
4185 "union MinimalTypeObject payload decode failed for tag `TK_ALIAS`: {err}"
4186 ),
4187 ))?;
4188 Ok(Self {
4189 tag: TK_ALIAS,
4190 data: MinimalTypeObjectData {
4191 alias_type: core::mem::ManuallyDrop::new(value),
4192 },
4193 })
4194 }
4195 "TK_ANNOTATION" => {
4196 let value = ::serde_json::from_value::<
4197 MinimalAnnotationType,
4198 >(helper.data)
4199 .map_err(|err| serde::de::Error::custom(
4200 format!(
4201 "union MinimalTypeObject payload decode failed for tag `TK_ANNOTATION`: {err}"
4202 ),
4203 ))?;
4204 Ok(Self {
4205 tag: TK_ANNOTATION,
4206 data: MinimalTypeObjectData {
4207 annotation_type: core::mem::ManuallyDrop::new(value),
4208 },
4209 })
4210 }
4211 "TK_STRUCTURE" => {
4212 let value = ::serde_json::from_value::<
4213 MinimalStructType,
4214 >(helper.data)
4215 .map_err(|err| serde::de::Error::custom(
4216 format!(
4217 "union MinimalTypeObject payload decode failed for tag `TK_STRUCTURE`: {err}"
4218 ),
4219 ))?;
4220 Ok(Self {
4221 tag: TK_STRUCTURE,
4222 data: MinimalTypeObjectData {
4223 struct_type: core::mem::ManuallyDrop::new(value),
4224 },
4225 })
4226 }
4227 "TK_UNION" => {
4228 let value = ::serde_json::from_value::<
4229 MinimalUnionType,
4230 >(helper.data)
4231 .map_err(|err| serde::de::Error::custom(
4232 format!(
4233 "union MinimalTypeObject payload decode failed for tag `TK_UNION`: {err}"
4234 ),
4235 ))?;
4236 Ok(Self {
4237 tag: TK_UNION,
4238 data: MinimalTypeObjectData {
4239 union_type: core::mem::ManuallyDrop::new(value),
4240 },
4241 })
4242 }
4243 "TK_BITSET" => {
4244 let value = ::serde_json::from_value::<
4245 MinimalBitsetType,
4246 >(helper.data)
4247 .map_err(|err| serde::de::Error::custom(
4248 format!(
4249 "union MinimalTypeObject payload decode failed for tag `TK_BITSET`: {err}"
4250 ),
4251 ))?;
4252 Ok(Self {
4253 tag: TK_BITSET,
4254 data: MinimalTypeObjectData {
4255 bitset_type: core::mem::ManuallyDrop::new(value),
4256 },
4257 })
4258 }
4259 "TK_SEQUENCE" => {
4260 let value = ::serde_json::from_value::<
4261 MinimalSequenceType,
4262 >(helper.data)
4263 .map_err(|err| serde::de::Error::custom(
4264 format!(
4265 "union MinimalTypeObject payload decode failed for tag `TK_SEQUENCE`: {err}"
4266 ),
4267 ))?;
4268 Ok(Self {
4269 tag: TK_SEQUENCE,
4270 data: MinimalTypeObjectData {
4271 sequence_type: core::mem::ManuallyDrop::new(value),
4272 },
4273 })
4274 }
4275 "TK_ARRAY" => {
4276 let value = ::serde_json::from_value::<
4277 MinimalArrayType,
4278 >(helper.data)
4279 .map_err(|err| serde::de::Error::custom(
4280 format!(
4281 "union MinimalTypeObject payload decode failed for tag `TK_ARRAY`: {err}"
4282 ),
4283 ))?;
4284 Ok(Self {
4285 tag: TK_ARRAY,
4286 data: MinimalTypeObjectData {
4287 array_type: core::mem::ManuallyDrop::new(value),
4288 },
4289 })
4290 }
4291 "TK_MAP" => {
4292 let value = ::serde_json::from_value::<
4293 MinimalMapType,
4294 >(helper.data)
4295 .map_err(|err| serde::de::Error::custom(
4296 format!(
4297 "union MinimalTypeObject payload decode failed for tag `TK_MAP`: {err}"
4298 ),
4299 ))?;
4300 Ok(Self {
4301 tag: TK_MAP,
4302 data: MinimalTypeObjectData {
4303 map_type: core::mem::ManuallyDrop::new(value),
4304 },
4305 })
4306 }
4307 "TK_ENUM" => {
4308 let value = ::serde_json::from_value::<
4309 MinimalEnumeratedType,
4310 >(helper.data)
4311 .map_err(|err| serde::de::Error::custom(
4312 format!(
4313 "union MinimalTypeObject payload decode failed for tag `TK_ENUM`: {err}"
4314 ),
4315 ))?;
4316 Ok(Self {
4317 tag: TK_ENUM,
4318 data: MinimalTypeObjectData {
4319 enumerated_type: core::mem::ManuallyDrop::new(value),
4320 },
4321 })
4322 }
4323 "TK_BITMASK" => {
4324 let value = ::serde_json::from_value::<
4325 MinimalBitmaskType,
4326 >(helper.data)
4327 .map_err(|err| serde::de::Error::custom(
4328 format!(
4329 "union MinimalTypeObject payload decode failed for tag `TK_BITMASK`: {err}"
4330 ),
4331 ))?;
4332 Ok(Self {
4333 tag: TK_BITMASK,
4334 data: MinimalTypeObjectData {
4335 bitmask_type: core::mem::ManuallyDrop::new(value),
4336 },
4337 })
4338 }
4339 "default" => {
4340 let value = ::serde_json::from_value::<
4341 MinimalExtendedType,
4342 >(helper.data)
4343 .map_err(|err| serde::de::Error::custom(
4344 format!(
4345 "union MinimalTypeObject payload decode failed for tag `default`: {err}"
4346 ),
4347 ))?;
4348 Ok(Self {
4349 tag: u8::default(),
4350 data: MinimalTypeObjectData {
4351 extended_type: core::mem::ManuallyDrop::new(value),
4352 },
4353 })
4354 }
4355 _ => Err(serde::de::Error::custom(format!(
4356 "union MinimalTypeObject tag/data mismatch for tag `{}`",
4357 helper.tag
4358 ))),
4359 }
4360 }
4361 }
4362 pub struct TypeObject {
4363 tag: u8,
4364 data: TypeObjectData,
4365 }
4366 union TypeObjectData {
4367 complete: core::mem::ManuallyDrop<CompleteTypeObject>,
4368 minimal: core::mem::ManuallyDrop<MinimalTypeObject>,
4369 }
4370 impl Drop for TypeObject {
4371 #[allow(unreachable_patterns)]
4372 fn drop(&mut self) {
4373 match self.tag {
4374 EK_COMPLETE => unsafe {
4375 core::mem::ManuallyDrop::drop(&mut self.data.complete);
4376 },
4377 EK_MINIMAL => unsafe {
4378 core::mem::ManuallyDrop::drop(&mut self.data.minimal);
4379 },
4380 _ => {}
4381 }
4382 }
4383 }
4384 impl Clone for TypeObject {
4385 #[allow(clippy::clone_on_copy)]
4386 #[allow(unreachable_patterns)]
4387 fn clone(&self) -> Self {
4388 match self.tag {
4389 EK_COMPLETE => Self::new_complete(self.as_complete().clone()),
4390 EK_MINIMAL => Self::new_minimal(self.as_minimal().clone()),
4391 _ => unreachable!(),
4392 }
4393 }
4394 }
4395 impl core::fmt::Debug for TypeObject {
4396 #[allow(unreachable_patterns)]
4397 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
4398 let mut d = f.debug_struct("TypeObject");
4399 d.field("tag", &self.tag);
4400 match self.tag {
4401 EK_COMPLETE => {
4402 d.field("complete", self.as_complete());
4403 }
4404 EK_MINIMAL => {
4405 d.field("minimal", self.as_minimal());
4406 }
4407 _ => {}
4408 }
4409 d.finish()
4410 }
4411 }
4412 impl PartialEq for TypeObject {
4413 #[allow(unreachable_patterns)]
4414 fn eq(&self, other: &Self) -> bool {
4415 if self.tag != other.tag {
4416 return false;
4417 }
4418 match self.tag {
4419 EK_COMPLETE => self.as_complete() == other.as_complete(),
4420 EK_MINIMAL => self.as_minimal() == other.as_minimal(),
4421 _ => false,
4422 }
4423 }
4424 }
4425 impl TypeObject {
4426 pub fn new_complete(value: CompleteTypeObject) -> Self {
4427 Self {
4428 tag: EK_COMPLETE,
4429 data: TypeObjectData {
4430 complete: core::mem::ManuallyDrop::new(value),
4431 },
4432 }
4433 }
4434 pub fn is_complete(&self) -> bool {
4435 matches!(self.tag, EK_COMPLETE)
4436 }
4437 #[allow(clippy::borrowed_box)]
4438 pub fn as_complete(&self) -> &CompleteTypeObject {
4439 debug_assert!(self.is_complete());
4440 unsafe { &self.data.complete }
4441 }
4442 #[allow(clippy::borrowed_box)]
4443 pub fn as_complete_mut(&mut self) -> &mut CompleteTypeObject {
4444 debug_assert!(self.is_complete());
4445 unsafe { &mut self.data.complete }
4446 }
4447 pub fn into_complete(self) -> CompleteTypeObject {
4448 debug_assert!(self.is_complete());
4449 unsafe {
4450 let mut forget = core::mem::ManuallyDrop::new(self);
4451 core::mem::ManuallyDrop::take(&mut forget.data.complete)
4452 }
4453 }
4454 pub fn new_minimal(value: MinimalTypeObject) -> Self {
4455 Self {
4456 tag: EK_MINIMAL,
4457 data: TypeObjectData {
4458 minimal: core::mem::ManuallyDrop::new(value),
4459 },
4460 }
4461 }
4462 pub fn is_minimal(&self) -> bool {
4463 matches!(self.tag, EK_MINIMAL)
4464 }
4465 #[allow(clippy::borrowed_box)]
4466 pub fn as_minimal(&self) -> &MinimalTypeObject {
4467 debug_assert!(self.is_minimal());
4468 unsafe { &self.data.minimal }
4469 }
4470 #[allow(clippy::borrowed_box)]
4471 pub fn as_minimal_mut(&mut self) -> &mut MinimalTypeObject {
4472 debug_assert!(self.is_minimal());
4473 unsafe { &mut self.data.minimal }
4474 }
4475 pub fn into_minimal(self) -> MinimalTypeObject {
4476 debug_assert!(self.is_minimal());
4477 unsafe {
4478 let mut forget = core::mem::ManuallyDrop::new(self);
4479 core::mem::ManuallyDrop::take(&mut forget.data.minimal)
4480 }
4481 }
4482 pub fn tag(&self) -> &u8 {
4483 &self.tag
4484 }
4485 }
4486 impl Default for TypeObject {
4487 fn default() -> Self {
4488 Self {
4489 tag: EK_COMPLETE,
4490 data: TypeObjectData {
4491 complete: core::mem::ManuallyDrop::new(CompleteTypeObject::default()),
4492 },
4493 }
4494 }
4495 }
4496 #[derive(::serde::Serialize)]
4497 struct TypeObjectSerdeRef<'__a> {
4498 tag: &'__a str,
4499 data: TypeObjectSerdeRefData<'__a>,
4500 }
4501 #[allow(clippy::borrowed_box)]
4502 #[derive(::serde::Serialize)]
4503 #[serde(untagged)]
4504 enum TypeObjectSerdeRefData<'__a> {
4505 Case0(&'__a CompleteTypeObject),
4506 Case1(&'__a MinimalTypeObject),
4507 }
4508 impl serde::Serialize for TypeObject {
4509 #[allow(unreachable_patterns)]
4510 fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
4511 where
4512 __S: serde::Serializer,
4513 {
4514 let helper = match self.tag {
4515 EK_COMPLETE => {
4516 let tag = "EK_COMPLETE";
4517 TypeObjectSerdeRef {
4518 tag,
4519 data: TypeObjectSerdeRefData::Case0(self.as_complete()),
4520 }
4521 }
4522 EK_MINIMAL => {
4523 let tag = "EK_MINIMAL";
4524 TypeObjectSerdeRef {
4525 tag,
4526 data: TypeObjectSerdeRefData::Case1(self.as_minimal()),
4527 }
4528 }
4529 _ => unreachable!(),
4530 };
4531 helper.serialize(__serializer)
4532 }
4533 }
4534 #[derive(::serde::Deserialize)]
4535 struct TypeObjectSerdeOwned {
4536 tag: String,
4537 data: ::serde_json::Value,
4538 }
4539 impl<'de> serde::Deserialize<'de> for TypeObject {
4540 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
4541 where
4542 D: serde::Deserializer<'de>,
4543 {
4544 let helper = TypeObjectSerdeOwned::deserialize(deserializer)?;
4545 match helper.tag.as_str() {
4546 "EK_COMPLETE" => {
4547 let value = ::serde_json::from_value::<
4548 CompleteTypeObject,
4549 >(helper.data)
4550 .map_err(|err| serde::de::Error::custom(
4551 format!(
4552 "union TypeObject payload decode failed for tag `EK_COMPLETE`: {err}"
4553 ),
4554 ))?;
4555 Ok(Self {
4556 tag: EK_COMPLETE,
4557 data: TypeObjectData {
4558 complete: core::mem::ManuallyDrop::new(value),
4559 },
4560 })
4561 }
4562 "EK_MINIMAL" => {
4563 let value = ::serde_json::from_value::<
4564 MinimalTypeObject,
4565 >(helper.data)
4566 .map_err(|err| serde::de::Error::custom(
4567 format!(
4568 "union TypeObject payload decode failed for tag `EK_MINIMAL`: {err}"
4569 ),
4570 ))?;
4571 Ok(Self {
4572 tag: EK_MINIMAL,
4573 data: TypeObjectData {
4574 minimal: core::mem::ManuallyDrop::new(value),
4575 },
4576 })
4577 }
4578 _ => Err(serde::de::Error::custom(format!(
4579 "union TypeObject tag/data mismatch for tag `{}`",
4580 helper.tag
4581 ))),
4582 }
4583 }
4584 }
4585 pub type TypeObjectSeq = Vec<TypeObject>;
4586 pub type StronglyConnectedComponent = TypeObjectSeq;
4587 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
4588 pub struct TypeIdentifierTypeObjectPair {
4589 pub type_identifier: TypeIdentifier,
4590 pub type_object: TypeObject,
4591 }
4592 impl TypeIdentifierTypeObjectPair {}
4593 pub type TypeIdentifierTypeObjectPairSeq = Vec<TypeIdentifierTypeObjectPair>;
4594 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
4595 pub struct TypeIdentifierPair {
4596 pub type_identifier1: TypeIdentifier,
4597 pub type_identifier2: TypeIdentifier,
4598 }
4599 impl TypeIdentifierPair {}
4600 pub type TypeIdentifierPairSeq = Vec<TypeIdentifierPair>;
4601 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
4602 pub struct TypeIdentifierWithSize {
4603 pub type_id: TypeIdentifier,
4604 pub typeobject_serialized_size: u32,
4605 }
4606 impl TypeIdentifierWithSize {}
4607 pub type TypeIdentifierWithSizeSeq = Vec<TypeIdentifierWithSize>;
4608 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
4609 pub struct TypeIdentifierWithDependencies {
4610 pub typeid_with_size: TypeIdentifierWithSize,
4611 pub dependent_typeid_count: i32,
4612 pub dependent_typeids: Vec<TypeIdentifierWithSize>,
4613 }
4614 impl TypeIdentifierWithDependencies {}
4615 pub type TypeIdentifierWithDependenciesSeq = Vec<TypeIdentifierWithDependencies>;
4616 #[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
4617 pub struct TypeInformation {
4618 pub minimal: TypeIdentifierWithDependencies,
4619 pub complete: TypeIdentifierWithDependencies,
4620 }
4621 impl TypeInformation {}
4622 pub type TypeInformationSeq = Vec<TypeInformation>;
4623 }
4624}