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 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 67 let b = unsafe { 68 flatbuffers::read_scalar_at::<i8>(buf, loc) 69 }; 70 Self(b) 71 } 72 } 73 74 impl flatbuffers::Push for Race { 75 type Output = Race; 76 #[inline] push(&self, dst: &mut [u8], _rest: &[u8])77 fn push(&self, dst: &mut [u8], _rest: &[u8]) { 78 unsafe { flatbuffers::emplace_scalar::<i8>(dst, self.0); } 79 } 80 } 81 82 impl flatbuffers::EndianScalar for Race { 83 #[inline] to_little_endian(self) -> Self84 fn to_little_endian(self) -> Self { 85 let b = i8::to_le(self.0); 86 Self(b) 87 } 88 #[inline] 89 #[allow(clippy::wrong_self_convention)] from_little_endian(self) -> Self90 fn from_little_endian(self) -> Self { 91 let b = i8::from_le(self.0); 92 Self(b) 93 } 94 } 95 96 impl<'a> flatbuffers::Verifiable for Race { 97 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>98 fn run_verifier( 99 v: &mut flatbuffers::Verifier, pos: usize 100 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 101 use self::flatbuffers::Verifiable; 102 i8::run_verifier(v, pos) 103 } 104 } 105 106 impl flatbuffers::SimpleToVerifyInSlice for Race {} 107