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 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 78 let b = flatbuffers::read_scalar_at::<i8>(buf, loc); 79 Self(b) 80 } 81 } 82 83 impl flatbuffers::Push for Race { 84 type Output = Race; 85 #[inline] push(&self, dst: &mut [u8], _written_len: usize)86 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 87 flatbuffers::emplace_scalar::<i8>(dst, self.0); 88 } 89 } 90 91 impl flatbuffers::EndianScalar for Race { 92 type Scalar = i8; 93 #[inline] to_little_endian(self) -> i894 fn to_little_endian(self) -> i8 { 95 self.0.to_le() 96 } 97 #[inline] 98 #[allow(clippy::wrong_self_convention)] from_little_endian(v: i8) -> Self99 fn from_little_endian(v: i8) -> Self { 100 let b = i8::from_le(v); 101 Self(b) 102 } 103 } 104 105 impl<'a> flatbuffers::Verifiable for Race { 106 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>107 fn run_verifier( 108 v: &mut flatbuffers::Verifier, pos: usize 109 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 110 use self::flatbuffers::Verifiable; 111 i8::run_verifier(v, pos) 112 } 113 } 114 115 impl flatbuffers::SimpleToVerifyInSlice for Race {} 116