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 extern crate serde; 11 use self::serde::ser::{Serialize, Serializer, SerializeStruct}; 12 use self::flatbuffers::{EndianScalar, Follow}; 13 use super::*; 14 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 pub const ENUM_MIN_RACE: i8 = -1; 16 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 pub const ENUM_MAX_RACE: i8 = 2; 18 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 19 #[allow(non_camel_case_types)] 20 pub const ENUM_VALUES_RACE: [Race; 4] = [ 21 Race::None, 22 Race::Human, 23 Race::Dwarf, 24 Race::Elf, 25 ]; 26 27 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 28 #[repr(transparent)] 29 pub struct Race(pub i8); 30 #[allow(non_upper_case_globals)] 31 impl Race { 32 pub const None: Self = Self(-1); 33 pub const Human: Self = Self(0); 34 pub const Dwarf: Self = Self(1); 35 pub const Elf: Self = Self(2); 36 37 pub const ENUM_MIN: i8 = -1; 38 pub const ENUM_MAX: i8 = 2; 39 pub const ENUM_VALUES: &'static [Self] = &[ 40 Self::None, 41 Self::Human, 42 Self::Dwarf, 43 Self::Elf, 44 ]; 45 /// Returns the variant's name or "" if unknown. variant_name(self) -> Option<&'static str>46 pub fn variant_name(self) -> Option<&'static str> { 47 match self { 48 Self::None => Some("None"), 49 Self::Human => Some("Human"), 50 Self::Dwarf => Some("Dwarf"), 51 Self::Elf => Some("Elf"), 52 _ => None, 53 } 54 } 55 } 56 impl core::fmt::Debug for Race { fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result57 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 58 if let Some(name) = self.variant_name() { 59 f.write_str(name) 60 } else { 61 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0)) 62 } 63 } 64 } 65 impl Serialize for Race { serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer,66 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 67 where 68 S: Serializer, 69 { 70 serializer.serialize_unit_variant("Race", self.0 as u32, self.variant_name().unwrap()) 71 } 72 } 73 74 impl<'a> flatbuffers::Follow<'a> for Race { 75 type Inner = Self; 76 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner77 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 78 let b = unsafe { 79 flatbuffers::read_scalar_at::<i8>(buf, loc) 80 }; 81 Self(b) 82 } 83 } 84 85 impl flatbuffers::Push for Race { 86 type Output = Race; 87 #[inline] push(&self, dst: &mut [u8], _rest: &[u8])88 fn push(&self, dst: &mut [u8], _rest: &[u8]) { 89 unsafe { flatbuffers::emplace_scalar::<i8>(dst, self.0); } 90 } 91 } 92 93 impl flatbuffers::EndianScalar for Race { 94 #[inline] to_little_endian(self) -> Self95 fn to_little_endian(self) -> Self { 96 let b = i8::to_le(self.0); 97 Self(b) 98 } 99 #[inline] 100 #[allow(clippy::wrong_self_convention)] from_little_endian(self) -> Self101 fn from_little_endian(self) -> Self { 102 let b = i8::from_le(self.0); 103 Self(b) 104 } 105 } 106 107 impl<'a> flatbuffers::Verifiable for Race { 108 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>109 fn run_verifier( 110 v: &mut flatbuffers::Verifier, pos: usize 111 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 112 use self::flatbuffers::Verifiable; 113 i8::run_verifier(v, pos) 114 } 115 } 116 117 impl flatbuffers::SimpleToVerifyInSlice for Race {} 118