• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
23     Self { _tab: flatbuffers::Table { 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 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>( _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, args: &'args StatArgs<'args> ) -> flatbuffers::WIPOffset<Stat<'bldr>>41   pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
42     _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
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     self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)
68   }
69   #[inline]
val(&self) -> i6470   pub fn val(&self) -> i64 {
71     self._tab.get::<i64>(Stat::VT_VAL, Some(0)).unwrap()
72   }
73   #[inline]
count(&self) -> u1674   pub fn count(&self) -> u16 {
75     self._tab.get::<u16>(Stat::VT_COUNT, Some(0)).unwrap()
76   }
77   #[inline]
key_compare_less_than(&self, o: &Stat) -> bool78   pub fn key_compare_less_than(&self, o: &Stat) -> bool {
79     self.count() < o.count()
80   }
81 
82   #[inline]
key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering83   pub fn key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering {
84     let key = self.count();
85     key.cmp(&val)
86   }
87 }
88 
89 impl flatbuffers::Verifiable for Stat<'_> {
90   #[inline]
run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>91   fn run_verifier(
92     v: &mut flatbuffers::Verifier, pos: usize
93   ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
94     use self::flatbuffers::Verifiable;
95     v.visit_table(pos)?
96      .visit_field::<flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)?
97      .visit_field::<i64>("val", Self::VT_VAL, false)?
98      .visit_field::<u16>("count", Self::VT_COUNT, false)?
99      .finish();
100     Ok(())
101   }
102 }
103 pub struct StatArgs<'a> {
104     pub id: Option<flatbuffers::WIPOffset<&'a str>>,
105     pub val: i64,
106     pub count: u16,
107 }
108 impl<'a> Default for StatArgs<'a> {
109   #[inline]
default() -> Self110   fn default() -> Self {
111     StatArgs {
112       id: None,
113       val: 0,
114       count: 0,
115     }
116   }
117 }
118 
119 pub struct StatBuilder<'a: 'b, 'b> {
120   fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
121   start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
122 }
123 impl<'a: 'b, 'b> StatBuilder<'a, 'b> {
124   #[inline]
add_id(&mut self, id: flatbuffers::WIPOffset<&'b str>)125   pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b  str>) {
126     self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Stat::VT_ID, id);
127   }
128   #[inline]
add_val(&mut self, val: i64)129   pub fn add_val(&mut self, val: i64) {
130     self.fbb_.push_slot::<i64>(Stat::VT_VAL, val, 0);
131   }
132   #[inline]
add_count(&mut self, count: u16)133   pub fn add_count(&mut self, count: u16) {
134     self.fbb_.push_slot::<u16>(Stat::VT_COUNT, count, 0);
135   }
136   #[inline]
new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> StatBuilder<'a, 'b>137   pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> StatBuilder<'a, 'b> {
138     let start = _fbb.start_table();
139     StatBuilder {
140       fbb_: _fbb,
141       start_: start,
142     }
143   }
144   #[inline]
finish(self) -> flatbuffers::WIPOffset<Stat<'a>>145   pub fn finish(self) -> flatbuffers::WIPOffset<Stat<'a>> {
146     let o = self.fbb_.end_table(self.start_);
147     flatbuffers::WIPOffset::new(o.value())
148   }
149 }
150 
151 impl core::fmt::Debug for Stat<'_> {
fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result152   fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
153     let mut ds = f.debug_struct("Stat");
154       ds.field("id", &self.id());
155       ds.field("val", &self.val());
156       ds.field("count", &self.count());
157       ds.finish()
158   }
159 }
160 #[non_exhaustive]
161 #[derive(Debug, Clone, PartialEq)]
162 pub struct StatT {
163   pub id: Option<String>,
164   pub val: i64,
165   pub count: u16,
166 }
167 impl Default for StatT {
default() -> Self168   fn default() -> Self {
169     Self {
170       id: None,
171       val: 0,
172       count: 0,
173     }
174   }
175 }
176 impl StatT {
pack<'b>( &self, _fbb: &mut flatbuffers::FlatBufferBuilder<'b> ) -> flatbuffers::WIPOffset<Stat<'b>>177   pub fn pack<'b>(
178     &self,
179     _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
180   ) -> flatbuffers::WIPOffset<Stat<'b>> {
181     let id = self.id.as_ref().map(|x|{
182       _fbb.create_string(x)
183     });
184     let val = self.val;
185     let count = self.count;
186     Stat::create(_fbb, &StatArgs{
187       id,
188       val,
189       count,
190     })
191   }
192 }
193