File: any_ambiguous_aliases_generated.rs

package info (click to toggle)
golang-github-google-flatbuffers 24.3.25-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 17,364 kB
  • sloc: cpp: 49,726; python: 6,901; cs: 5,566; java: 4,370; ansic: 2,512; php: 1,460; javascript: 1,053; xml: 1,016; sh: 870; makefile: 13
file content (212 lines) | stat: -rw-r--r-- 6,721 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;
extern crate flatbuffers;
use alloc::boxed::Box;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::mem;
use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ANY_AMBIGUOUS_ALIASES: u8 = 0;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ANY_AMBIGUOUS_ALIASES: u8 = 3;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_ANY_AMBIGUOUS_ALIASES: [AnyAmbiguousAliases; 4] = [
  AnyAmbiguousAliases::NONE,
  AnyAmbiguousAliases::M1,
  AnyAmbiguousAliases::M2,
  AnyAmbiguousAliases::M3,
];

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct AnyAmbiguousAliases(pub u8);
#[allow(non_upper_case_globals)]
impl AnyAmbiguousAliases {
  pub const NONE: Self = Self(0);
  pub const M1: Self = Self(1);
  pub const M2: Self = Self(2);
  pub const M3: Self = Self(3);

  pub const ENUM_MIN: u8 = 0;
  pub const ENUM_MAX: u8 = 3;
  pub const ENUM_VALUES: &'static [Self] = &[
    Self::NONE,
    Self::M1,
    Self::M2,
    Self::M3,
  ];
  /// Returns the variant's name or "" if unknown.
  pub fn variant_name(self) -> Option<&'static str> {
    match self {
      Self::NONE => Some("NONE"),
      Self::M1 => Some("M1"),
      Self::M2 => Some("M2"),
      Self::M3 => Some("M3"),
      _ => None,
    }
  }
}
impl core::fmt::Debug for AnyAmbiguousAliases {
  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
    if let Some(name) = self.variant_name() {
      f.write_str(name)
    } else {
      f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
    }
  }
}
impl Serialize for AnyAmbiguousAliases {
  fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
  where
    S: Serializer,
  {
    serializer.serialize_unit_variant("AnyAmbiguousAliases", self.0 as u32, self.variant_name().unwrap())
  }
}

impl<'a> flatbuffers::Follow<'a> for AnyAmbiguousAliases {
  type Inner = Self;
  #[inline]
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
    Self(b)
  }
}

impl flatbuffers::Push for AnyAmbiguousAliases {
    type Output = AnyAmbiguousAliases;
    #[inline]
    unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
        flatbuffers::emplace_scalar::<u8>(dst, self.0);
    }
}

impl flatbuffers::EndianScalar for AnyAmbiguousAliases {
  type Scalar = u8;
  #[inline]
  fn to_little_endian(self) -> u8 {
    self.0.to_le()
  }
  #[inline]
  #[allow(clippy::wrong_self_convention)]
  fn from_little_endian(v: u8) -> Self {
    let b = u8::from_le(v);
    Self(b)
  }
}

impl<'a> flatbuffers::Verifiable for AnyAmbiguousAliases {
  #[inline]
  fn run_verifier(
    v: &mut flatbuffers::Verifier, pos: usize
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
    use self::flatbuffers::Verifiable;
    u8::run_verifier(v, pos)
  }
}

impl flatbuffers::SimpleToVerifyInSlice for AnyAmbiguousAliases {}
pub struct AnyAmbiguousAliasesUnionTableOffset {}

#[allow(clippy::upper_case_acronyms)]
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum AnyAmbiguousAliasesT {
  NONE,
  M1(Box<MonsterT>),
  M2(Box<MonsterT>),
  M3(Box<MonsterT>),
}
impl Default for AnyAmbiguousAliasesT {
  fn default() -> Self {
    Self::NONE
  }
}
impl AnyAmbiguousAliasesT {
  pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
    match self {
      Self::NONE => AnyAmbiguousAliases::NONE,
      Self::M1(_) => AnyAmbiguousAliases::M1,
      Self::M2(_) => AnyAmbiguousAliases::M2,
      Self::M3(_) => AnyAmbiguousAliases::M3,
    }
  }
  pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
    match self {
      Self::NONE => None,
      Self::M1(v) => Some(v.pack(fbb).as_union_value()),
      Self::M2(v) => Some(v.pack(fbb).as_union_value()),
      Self::M3(v) => Some(v.pack(fbb).as_union_value()),
    }
  }
  /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
  pub fn take_m1(&mut self) -> Option<Box<MonsterT>> {
    if let Self::M1(_) = self {
      let v = core::mem::replace(self, Self::NONE);
      if let Self::M1(w) = v {
        Some(w)
      } else {
        unreachable!()
      }
    } else {
      None
    }
  }
  /// If the union variant matches, return a reference to the MonsterT.
  pub fn as_m1(&self) -> Option<&MonsterT> {
    if let Self::M1(v) = self { Some(v.as_ref()) } else { None }
  }
  /// If the union variant matches, return a mutable reference to the MonsterT.
  pub fn as_m1_mut(&mut self) -> Option<&mut MonsterT> {
    if let Self::M1(v) = self { Some(v.as_mut()) } else { None }
  }
  /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
  pub fn take_m2(&mut self) -> Option<Box<MonsterT>> {
    if let Self::M2(_) = self {
      let v = core::mem::replace(self, Self::NONE);
      if let Self::M2(w) = v {
        Some(w)
      } else {
        unreachable!()
      }
    } else {
      None
    }
  }
  /// If the union variant matches, return a reference to the MonsterT.
  pub fn as_m2(&self) -> Option<&MonsterT> {
    if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
  }
  /// If the union variant matches, return a mutable reference to the MonsterT.
  pub fn as_m2_mut(&mut self) -> Option<&mut MonsterT> {
    if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
  }
  /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
  pub fn take_m3(&mut self) -> Option<Box<MonsterT>> {
    if let Self::M3(_) = self {
      let v = core::mem::replace(self, Self::NONE);
      if let Self::M3(w) = v {
        Some(w)
      } else {
        unreachable!()
      }
    } else {
      None
    }
  }
  /// If the union variant matches, return a reference to the MonsterT.
  pub fn as_m3(&self) -> Option<&MonsterT> {
    if let Self::M3(v) = self { Some(v.as_ref()) } else { None }
  }
  /// If the union variant matches, return a mutable reference to the MonsterT.
  pub fn as_m3_mut(&mut self) -> Option<&mut MonsterT> {
    if let Self::M3(v) = self { Some(v.as_mut()) } else { None }
  }
}