Debian Codegraph @

tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs

raw
1 // automatically generated by the FlatBuffers compiler, do not modify
2 // @generated
3 extern crate alloc;
4 extern crate flatbuffers;
5 use alloc::boxed::Box;
6 use alloc::string::{String, ToString};
7 use alloc::vec::Vec;
8 use core::mem;
9 use core::cmp::Ordering;
10 use self::flatbuffers::{EndianScalar, Follow};
11 use super::*;
12 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
13 pub const ENUM_MIN_UNION_IN_NESTED_NS: u8 = 0;
14 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
15 pub const ENUM_MAX_UNION_IN_NESTED_NS: u8 = 1;
16 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
17 #[allow(non_camel_case_types)]
18 pub const ENUM_VALUES_UNION_IN_NESTED_NS: [UnionInNestedNS; 2] = [
19 UnionInNestedNS::NONE,
20 UnionInNestedNS::TableInNestedNS,
21 ];
22
23 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
24 #[repr(transparent)]
25 pub struct UnionInNestedNS(pub u8);
26 #[allow(non_upper_case_globals)]
27 impl UnionInNestedNS {
28 pub const NONE: Self = Self(0);
29 pub const TableInNestedNS: Self = Self(1);
30
31 pub const ENUM_MIN: u8 = 0;
32 pub const ENUM_MAX: u8 = 1;
33 pub const ENUM_VALUES: &'static [Self] = &[
34 Self::NONE,
35 Self::TableInNestedNS,
36 ];
37 /// Returns the variant's name or "" if unknown.
38 pub fn variant_name(self) -> Option<&'static str> {
39 match self {
40 Self::NONE => Some("NONE"),
41 Self::TableInNestedNS => Some("TableInNestedNS"),
42 _ => None,
43 }
44 }
45 }
46 impl core::fmt::Debug for UnionInNestedNS {
47 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
48 if let Some(name) = self.variant_name() {
49 f.write_str(name)
50 } else {
51 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
52 }
53 }
54 }
55 impl<'a> flatbuffers::Follow<'a> for UnionInNestedNS {
56 type Inner = Self;
57 #[inline]
58 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
59 let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
60 Self(b)
61 }
62 }
63
64 impl flatbuffers::Push for UnionInNestedNS {
65 type Output = UnionInNestedNS;
66 #[inline]
67 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
68 flatbuffers::emplace_scalar::<u8>(dst, self.0);
69 }
70 }
71
72 impl flatbuffers::EndianScalar for UnionInNestedNS {
73 type Scalar = u8;
74 #[inline]
75 fn to_little_endian(self) -> u8 {
76 self.0.to_le()
77 }
78 #[inline]
79 #[allow(clippy::wrong_self_convention)]
80 fn from_little_endian(v: u8) -> Self {
81 let b = u8::from_le(v);
82 Self(b)
83 }
84 }
85
86 impl<'a> flatbuffers::Verifiable for UnionInNestedNS {
87 #[inline]
88 fn run_verifier(
89 v: &mut flatbuffers::Verifier, pos: usize
90 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
91 use self::flatbuffers::Verifiable;
92 u8::run_verifier(v, pos)
93 }
94 }
95
96 impl flatbuffers::SimpleToVerifyInSlice for UnionInNestedNS {}
97 pub struct UnionInNestedNSUnionTableOffset {}
98
99 #[allow(clippy::upper_case_acronyms)]
100 #[non_exhaustive]
101 #[derive(Debug, Clone, PartialEq)]
102 pub enum UnionInNestedNST {
103 NONE,
104 TableInNestedNS(Box<TableInNestedNST>),
105 }
106 impl Default for UnionInNestedNST {
107 fn default() -> Self {
108 Self::NONE
109 }
110 }
111 impl UnionInNestedNST {
112 pub fn union_in_nested_ns_type(&self) -> UnionInNestedNS {
113 match self {
114 Self::NONE => UnionInNestedNS::NONE,
115 Self::TableInNestedNS(_) => UnionInNestedNS::TableInNestedNS,
116 }
117 }
118 pub fn pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
119 match self {
120 Self::NONE => None,
121 Self::TableInNestedNS(v) => Some(v.pack(fbb).as_union_value()),
122 }
123 }
124 /// If the union variant matches, return the owned TableInNestedNST, setting the union to NONE.
125 pub fn take_table_in_nested_ns(&mut self) -> Option<Box<TableInNestedNST>> {
126 if let Self::TableInNestedNS(_) = self {
127 let v = core::mem::replace(self, Self::NONE);
128 if let Self::TableInNestedNS(w) = v {
129 Some(w)
130 } else {
131 unreachable!()
132 }
133 } else {
134 None
135 }
136 }
137 /// If the union variant matches, return a reference to the TableInNestedNST.
138 pub fn as_table_in_nested_ns(&self) -> Option<&TableInNestedNST> {
139 if let Self::TableInNestedNS(v) = self { Some(v.as_ref()) } else { None }
140 }
141 /// If the union variant matches, return a mutable reference to the TableInNestedNST.
142 pub fn as_table_in_nested_ns_mut(&mut self) -> Option<&mut TableInNestedNST> {
143 if let Self::TableInNestedNS(v) = self { Some(v.as_mut()) } else { None }
144 }
145 }