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