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_RACE: i8 = -1; 14 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 pub 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)] 18 pub 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)] 27 pub struct Race(pub i8); 28 #[allow(non_upper_case_globals)] 29 impl 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. variant_name(self) -> Option<&'static str>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 } 54 impl core::fmt::Debug for Race { fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result55 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 } 63 impl<'a> flatbuffers::Follow<'a> for Race { 64 type Inner = Self; 65 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner66 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 72 impl flatbuffers::Push for Race { 73 type Output = Race; 74 #[inline] push(&self, dst: &mut [u8], _written_len: usize)75 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 76 flatbuffers::emplace_scalar::<i8>(dst, self.0); 77 } 78 } 79 80 impl flatbuffers::EndianScalar for Race { 81 type Scalar = i8; 82 #[inline] to_little_endian(self) -> i883 fn to_little_endian(self) -> i8 { 84 self.0.to_le() 85 } 86 #[inline] 87 #[allow(clippy::wrong_self_convention)] from_little_endian(v: i8) -> Self88 fn from_little_endian(v: i8) -> Self { 89 let b = i8::from_le(v); 90 Self(b) 91 } 92 } 93 94 impl<'a> flatbuffers::Verifiable for Race { 95 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>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 104 impl flatbuffers::SimpleToVerifyInSlice for Race {} 105