blob: 8622d9ba1872f46834691a1965221f096f4cf98e [file] [log] [blame]
James Kuszmaul8e62b022022-03-22 09:33:25 -07001// automatically generated by the FlatBuffers compiler, do not modify
2extern crate flatbuffers;
3use std::mem;
4use std::cmp::Ordering;
5use self::flatbuffers::{EndianScalar, Follow};
6use super::*;
7#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
8pub const ENUM_MIN_ABC: i32 = 0;
9#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
10pub const ENUM_MAX_ABC: i32 = 2;
11#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
12#[allow(non_camel_case_types)]
13pub const ENUM_VALUES_ABC: [ABC; 3] = [
14 ABC::A,
15 ABC::B,
16 ABC::C,
17];
18
19#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
20#[repr(transparent)]
21pub struct ABC(pub i32);
22#[allow(non_upper_case_globals)]
23impl ABC {
24 pub const A: Self = Self(0);
25 pub const B: Self = Self(1);
26 pub const C: Self = Self(2);
27
28 pub const ENUM_MIN: i32 = 0;
29 pub const ENUM_MAX: i32 = 2;
30 pub const ENUM_VALUES: &'static [Self] = &[
31 Self::A,
32 Self::B,
33 Self::C,
34 ];
35 /// Returns the variant's name or "" if unknown.
36 pub fn variant_name(self) -> Option<&'static str> {
37 match self {
38 Self::A => Some("A"),
39 Self::B => Some("B"),
40 Self::C => Some("C"),
41 _ => None,
42 }
43 }
44}
45impl std::fmt::Debug for ABC {
46 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
47 if let Some(name) = self.variant_name() {
48 f.write_str(name)
49 } else {
50 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
51 }
52 }
53}
54impl<'a> flatbuffers::Follow<'a> for ABC {
55 type Inner = Self;
56 #[inline]
57 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
58 let b = unsafe {
59 flatbuffers::read_scalar_at::<i32>(buf, loc)
60 };
61 Self(b)
62 }
63}
64
65impl flatbuffers::Push for ABC {
66 type Output = ABC;
67 #[inline]
68 fn push(&self, dst: &mut [u8], _rest: &[u8]) {
69 unsafe { flatbuffers::emplace_scalar::<i32>(dst, self.0); }
70 }
71}
72
73impl flatbuffers::EndianScalar for ABC {
74 #[inline]
75 fn to_little_endian(self) -> Self {
76 let b = i32::to_le(self.0);
77 Self(b)
78 }
79 #[inline]
80 #[allow(clippy::wrong_self_convention)]
81 fn from_little_endian(self) -> Self {
82 let b = i32::from_le(self.0);
83 Self(b)
84 }
85}
86
87impl<'a> flatbuffers::Verifiable for ABC {
88 #[inline]
89 fn run_verifier(
90 v: &mut flatbuffers::Verifier, pos: usize
91 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
92 use self::flatbuffers::Verifiable;
93 i32::run_verifier(v, pos)
94 }
95}
96
97impl flatbuffers::SimpleToVerifyInSlice for ABC {}