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