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 pub enum StatOffset {} 13 #[derive(Copy, Clone, PartialEq)] 14 15 pub struct Stat<'a> { 16 pub _tab: flatbuffers::Table<'a>, 17 } 18 19 impl<'a> flatbuffers::Follow<'a> for Stat<'a> { 20 type Inner = Stat<'a>; 21 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner22 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 Self { _tab: flatbuffers::Table::new(buf, loc) } 24 } 25 } 26 27 impl<'a> Stat<'a> { 28 pub const VT_ID: flatbuffers::VOffsetT = 4; 29 pub const VT_VAL: flatbuffers::VOffsetT = 6; 30 pub const VT_COUNT: flatbuffers::VOffsetT = 8; 31 get_fully_qualified_name() -> &'static str32 pub const fn get_fully_qualified_name() -> &'static str { 33 "MyGame.Example.Stat" 34 } 35 36 #[inline] init_from_table(table: flatbuffers::Table<'a>) -> Self37 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 38 Stat { _tab: table } 39 } 40 #[allow(unused_mut)] create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args StatArgs<'args> ) -> flatbuffers::WIPOffset<Stat<'bldr>>41 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 42 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 43 args: &'args StatArgs<'args> 44 ) -> flatbuffers::WIPOffset<Stat<'bldr>> { 45 let mut builder = StatBuilder::new(_fbb); 46 builder.add_val(args.val); 47 if let Some(x) = args.id { builder.add_id(x); } 48 builder.add_count(args.count); 49 builder.finish() 50 } 51 unpack(&self) -> StatT52 pub fn unpack(&self) -> StatT { 53 let id = self.id().map(|x| { 54 x.to_string() 55 }); 56 let val = self.val(); 57 let count = self.count(); 58 StatT { 59 id, 60 val, 61 count, 62 } 63 } 64 65 #[inline] id(&self) -> Option<&'a str>66 pub fn id(&self) -> Option<&'a str> { 67 // Safety: 68 // Created from valid Table for this object 69 // which contains a valid value in this slot 70 unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)} 71 } 72 #[inline] val(&self) -> i6473 pub fn val(&self) -> i64 { 74 // Safety: 75 // Created from valid Table for this object 76 // which contains a valid value in this slot 77 unsafe { self._tab.get::<i64>(Stat::VT_VAL, Some(0)).unwrap()} 78 } 79 #[inline] count(&self) -> u1680 pub fn count(&self) -> u16 { 81 // Safety: 82 // Created from valid Table for this object 83 // which contains a valid value in this slot 84 unsafe { self._tab.get::<u16>(Stat::VT_COUNT, Some(0)).unwrap()} 85 } 86 #[inline] key_compare_less_than(&self, o: &Stat) -> bool87 pub fn key_compare_less_than(&self, o: &Stat) -> bool { 88 self.count() < o.count() 89 } 90 91 #[inline] key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering92 pub fn key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering { 93 let key = self.count(); 94 key.cmp(&val) 95 } 96 } 97 98 impl flatbuffers::Verifiable for Stat<'_> { 99 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>100 fn run_verifier( 101 v: &mut flatbuffers::Verifier, pos: usize 102 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 103 use self::flatbuffers::Verifiable; 104 v.visit_table(pos)? 105 .visit_field::<flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)? 106 .visit_field::<i64>("val", Self::VT_VAL, false)? 107 .visit_field::<u16>("count", Self::VT_COUNT, false)? 108 .finish(); 109 Ok(()) 110 } 111 } 112 pub struct StatArgs<'a> { 113 pub id: Option<flatbuffers::WIPOffset<&'a str>>, 114 pub val: i64, 115 pub count: u16, 116 } 117 impl<'a> Default for StatArgs<'a> { 118 #[inline] default() -> Self119 fn default() -> Self { 120 StatArgs { 121 id: None, 122 val: 0, 123 count: 0, 124 } 125 } 126 } 127 128 pub struct StatBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 129 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 130 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>, 131 } 132 impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> StatBuilder<'a, 'b, A> { 133 #[inline] add_id(&mut self, id: flatbuffers::WIPOffset<&'b str>)134 pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b str>) { 135 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Stat::VT_ID, id); 136 } 137 #[inline] add_val(&mut self, val: i64)138 pub fn add_val(&mut self, val: i64) { 139 self.fbb_.push_slot::<i64>(Stat::VT_VAL, val, 0); 140 } 141 #[inline] add_count(&mut self, count: u16)142 pub fn add_count(&mut self, count: u16) { 143 self.fbb_.push_slot::<u16>(Stat::VT_COUNT, count, 0); 144 } 145 #[inline] new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A>146 pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A> { 147 let start = _fbb.start_table(); 148 StatBuilder { 149 fbb_: _fbb, 150 start_: start, 151 } 152 } 153 #[inline] finish(self) -> flatbuffers::WIPOffset<Stat<'a>>154 pub fn finish(self) -> flatbuffers::WIPOffset<Stat<'a>> { 155 let o = self.fbb_.end_table(self.start_); 156 flatbuffers::WIPOffset::new(o.value()) 157 } 158 } 159 160 impl core::fmt::Debug for Stat<'_> { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result161 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 162 let mut ds = f.debug_struct("Stat"); 163 ds.field("id", &self.id()); 164 ds.field("val", &self.val()); 165 ds.field("count", &self.count()); 166 ds.finish() 167 } 168 } 169 #[non_exhaustive] 170 #[derive(Debug, Clone, PartialEq)] 171 pub struct StatT { 172 pub id: Option<String>, 173 pub val: i64, 174 pub count: u16, 175 } 176 impl Default for StatT { default() -> Self177 fn default() -> Self { 178 Self { 179 id: None, 180 val: 0, 181 count: 0, 182 } 183 } 184 } 185 impl StatT { pack<'b, A: flatbuffers::Allocator + 'b>( &self, _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A> ) -> flatbuffers::WIPOffset<Stat<'b>>186 pub fn pack<'b, A: flatbuffers::Allocator + 'b>( 187 &self, 188 _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A> 189 ) -> flatbuffers::WIPOffset<Stat<'b>> { 190 let id = self.id.as_ref().map(|x|{ 191 _fbb.create_string(x) 192 }); 193 let val = self.val; 194 let count = self.count; 195 Stat::create(_fbb, &StatArgs{ 196 id, 197 val, 198 count, 199 }) 200 } 201 } 202