1
1
// automatically generated by the FlatBuffers compiler, do not modify
2
2
3
3
4
+
5
+ use core:: mem;
6
+ use core:: cmp:: Ordering ;
7
+
8
+ extern crate flatbuffers;
9
+ use self :: flatbuffers:: EndianScalar ;
10
+
11
+ #[ allow( unused_imports, dead_code) ]
4
12
pub mod my_game {
5
- #![ allow( dead_code) ]
6
- #![ allow( unused_imports) ]
7
13
8
- use std:: mem;
9
- use std:: marker:: PhantomData ;
10
- use std:: cmp:: Ordering ;
14
+ use core:: mem;
15
+ use core:: cmp:: Ordering ;
11
16
12
17
extern crate flatbuffers;
13
18
use self :: flatbuffers:: EndianScalar ;
19
+ #[ allow( unused_imports, dead_code) ]
14
20
pub mod sample {
15
- #![ allow( dead_code) ]
16
- #![ allow( unused_imports) ]
17
21
18
- use std:: mem;
19
- use std:: marker:: PhantomData ;
20
- use std:: cmp:: Ordering ;
22
+ use core:: mem;
23
+ use core:: cmp:: Ordering ;
21
24
22
25
extern crate flatbuffers;
23
26
use self :: flatbuffers:: EndianScalar ;
24
27
25
28
#[ allow( non_camel_case_types) ]
26
29
#[ repr( i8 ) ]
27
- #[ derive( Clone , Copy , PartialEq , Debug ) ]
30
+ #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
28
31
pub enum Color {
29
32
Red = 0 ,
30
33
Green = 1 ,
31
- Blue = 2
34
+ Blue = 2 ,
35
+
32
36
}
33
37
34
38
const ENUM_MIN_COLOR : i8 = 0 ;
@@ -80,16 +84,17 @@ const ENUM_NAMES_COLOR:[&'static str; 3] = [
80
84
] ;
81
85
82
86
pub fn enum_name_color ( e : Color ) -> & ' static str {
83
- let index: usize = e as usize ;
84
- ENUM_NAMES_COLOR [ index]
87
+ let index = e as i8 ;
88
+ ENUM_NAMES_COLOR [ index as usize ]
85
89
}
86
90
87
91
#[ allow( non_camel_case_types) ]
88
92
#[ repr( u8 ) ]
89
- #[ derive( Clone , Copy , PartialEq , Debug ) ]
93
+ #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
90
94
pub enum Equipment {
91
95
NONE = 0 ,
92
- Weapon = 1
96
+ Weapon = 1 ,
97
+
93
98
}
94
99
95
100
const ENUM_MIN_EQUIPMENT : u8 = 0 ;
@@ -139,8 +144,8 @@ const ENUM_NAMES_EQUIPMENT:[&'static str; 2] = [
139
144
] ;
140
145
141
146
pub fn enum_name_equipment ( e : Equipment ) -> & ' static str {
142
- let index: usize = e as usize ;
143
- ENUM_NAMES_EQUIPMENT [ index]
147
+ let index = e as u8 ;
148
+ ENUM_NAMES_EQUIPMENT [ index as usize ]
144
149
}
145
150
146
151
pub struct EquipmentUnionTableOffset { }
@@ -158,7 +163,6 @@ impl<'a> flatbuffers::Follow<'a> for Vec3 {
158
163
#[ inline]
159
164
fn follow ( buf : & ' a [ u8 ] , loc : usize ) -> Self :: Inner {
160
165
<& ' a Vec3 >:: follow ( buf, loc)
161
- //flatbuffers::follow_cast_ref::<Vec3>(buf, loc)
162
166
}
163
167
}
164
168
impl < ' a > flatbuffers:: Follow < ' a > for & ' a Vec3 {
@@ -173,7 +177,7 @@ impl<'b> flatbuffers::Push for Vec3 {
173
177
#[ inline]
174
178
fn push ( & self , dst : & mut [ u8 ] , _rest : & [ u8 ] ) {
175
179
let src = unsafe {
176
- :: std :: slice:: from_raw_parts ( self as * const Vec3 as * const u8 , Self :: size ( ) )
180
+ :: core :: slice:: from_raw_parts ( self as * const Vec3 as * const u8 , Self :: size ( ) )
177
181
} ;
178
182
dst. copy_from_slice ( src) ;
179
183
}
@@ -184,7 +188,7 @@ impl<'b> flatbuffers::Push for &'b Vec3 {
184
188
#[ inline]
185
189
fn push ( & self , dst : & mut [ u8 ] , _rest : & [ u8 ] ) {
186
190
let src = unsafe {
187
- :: std :: slice:: from_raw_parts ( * self as * const Vec3 as * const u8 , Self :: size ( ) )
191
+ :: core :: slice:: from_raw_parts ( * self as * const Vec3 as * const u8 , Self :: size ( ) )
188
192
} ;
189
193
dst. copy_from_slice ( src) ;
190
194
}
@@ -240,6 +244,7 @@ impl<'a> Monster<'a> {
240
244
_fbb : & ' mut_bldr mut flatbuffers:: FlatBufferBuilder < ' bldr > ,
241
245
args : & ' args MonsterArgs < ' args > ) -> flatbuffers:: WIPOffset < Monster < ' bldr > > {
242
246
let mut builder = MonsterBuilder :: new ( _fbb) ;
247
+ if let Some ( x) = args. path { builder. add_path ( x) ; }
243
248
if let Some ( x) = args. equipped { builder. add_equipped ( x) ; }
244
249
if let Some ( x) = args. weapons { builder. add_weapons ( x) ; }
245
250
if let Some ( x) = args. inventory { builder. add_inventory ( x) ; }
@@ -261,46 +266,51 @@ impl<'a> Monster<'a> {
261
266
pub const VT_WEAPONS : flatbuffers:: VOffsetT = 18 ;
262
267
pub const VT_EQUIPPED_TYPE : flatbuffers:: VOffsetT = 20 ;
263
268
pub const VT_EQUIPPED : flatbuffers:: VOffsetT = 22 ;
269
+ pub const VT_PATH : flatbuffers:: VOffsetT = 24 ;
264
270
265
271
#[ inline]
266
- pub fn pos ( & ' a self ) -> Option < & ' a Vec3 > {
272
+ pub fn pos ( & self ) -> Option < & ' a Vec3 > {
267
273
self . _tab . get :: < Vec3 > ( Monster :: VT_POS , None )
268
274
}
269
275
#[ inline]
270
- pub fn mana ( & ' a self ) -> i16 {
276
+ pub fn mana ( & self ) -> i16 {
271
277
self . _tab . get :: < i16 > ( Monster :: VT_MANA , Some ( 150 ) ) . unwrap ( )
272
278
}
273
279
#[ inline]
274
- pub fn hp ( & ' a self ) -> i16 {
280
+ pub fn hp ( & self ) -> i16 {
275
281
self . _tab . get :: < i16 > ( Monster :: VT_HP , Some ( 100 ) ) . unwrap ( )
276
282
}
277
283
#[ inline]
278
- pub fn name ( & ' a self ) -> Option < & ' a str > {
284
+ pub fn name ( & self ) -> Option < & ' a str > {
279
285
self . _tab . get :: < flatbuffers:: ForwardsUOffset < & str > > ( Monster :: VT_NAME , None )
280
286
}
281
287
#[ inline]
282
- pub fn inventory ( & ' a self ) -> Option < & ' a [ u8 ] > {
288
+ pub fn inventory ( & self ) -> Option < & ' a [ u8 ] > {
283
289
self . _tab . get :: < flatbuffers:: ForwardsUOffset < flatbuffers:: Vector < ' a , u8 > > > ( Monster :: VT_INVENTORY , None ) . map ( |v| v. safe_slice ( ) )
284
290
}
285
291
#[ inline]
286
- pub fn color ( & ' a self ) -> Color {
292
+ pub fn color ( & self ) -> Color {
287
293
self . _tab . get :: < Color > ( Monster :: VT_COLOR , Some ( Color :: Blue ) ) . unwrap ( )
288
294
}
289
295
#[ inline]
290
- pub fn weapons ( & ' a self ) -> Option < flatbuffers:: Vector < flatbuffers:: ForwardsUOffset < Weapon < ' a > > > > {
296
+ pub fn weapons ( & self ) -> Option < flatbuffers:: Vector < ' a , flatbuffers:: ForwardsUOffset < Weapon < ' a > > > > {
291
297
self . _tab . get :: < flatbuffers:: ForwardsUOffset < flatbuffers:: Vector < flatbuffers:: ForwardsUOffset < Weapon < ' a > > > > > ( Monster :: VT_WEAPONS , None )
292
298
}
293
299
#[ inline]
294
- pub fn equipped_type ( & ' a self ) -> Equipment {
300
+ pub fn equipped_type ( & self ) -> Equipment {
295
301
self . _tab . get :: < Equipment > ( Monster :: VT_EQUIPPED_TYPE , Some ( Equipment :: NONE ) ) . unwrap ( )
296
302
}
297
303
#[ inline]
298
- pub fn equipped ( & ' a self ) -> Option < flatbuffers:: Table < ' a > > {
304
+ pub fn equipped ( & self ) -> Option < flatbuffers:: Table < ' a > > {
299
305
self . _tab . get :: < flatbuffers:: ForwardsUOffset < flatbuffers:: Table < ' a > > > ( Monster :: VT_EQUIPPED , None )
300
306
}
301
307
#[ inline]
308
+ pub fn path ( & self ) -> Option < & ' a [ Vec3 ] > {
309
+ self . _tab . get :: < flatbuffers:: ForwardsUOffset < flatbuffers:: Vector < Vec3 > > > ( Monster :: VT_PATH , None ) . map ( |v| v. safe_slice ( ) )
310
+ }
311
+ #[ inline]
302
312
#[ allow( non_snake_case) ]
303
- pub fn equipped_as_weapon ( & ' a self ) -> Option < Weapon > {
313
+ pub fn equipped_as_weapon ( & self ) -> Option < Weapon < ' a > > {
304
314
if self . equipped_type ( ) == Equipment :: Weapon {
305
315
self . equipped ( ) . map ( |u| Weapon :: init_from_table ( u) )
306
316
} else {
@@ -320,6 +330,7 @@ pub struct MonsterArgs<'a> {
320
330
pub weapons : Option < flatbuffers:: WIPOffset < flatbuffers:: Vector < ' a , flatbuffers:: ForwardsUOffset < Weapon < ' a > > > > > ,
321
331
pub equipped_type : Equipment ,
322
332
pub equipped : Option < flatbuffers:: WIPOffset < flatbuffers:: UnionWIPOffset > > ,
333
+ pub path : Option < flatbuffers:: WIPOffset < flatbuffers:: Vector < ' a , Vec3 > > > ,
323
334
}
324
335
impl < ' a > Default for MonsterArgs < ' a > {
325
336
#[ inline]
@@ -334,6 +345,7 @@ impl<'a> Default for MonsterArgs<'a> {
334
345
weapons : None ,
335
346
equipped_type : Equipment :: NONE ,
336
347
equipped : None ,
348
+ path : None ,
337
349
}
338
350
}
339
351
}
@@ -379,6 +391,10 @@ impl<'a: 'b, 'b> MonsterBuilder<'a, 'b> {
379
391
self . fbb_ . push_slot_always :: < flatbuffers:: WIPOffset < _ > > ( Monster :: VT_EQUIPPED , equipped) ;
380
392
}
381
393
#[ inline]
394
+ pub fn add_path ( & mut self , path : flatbuffers:: WIPOffset < flatbuffers:: Vector < ' b , Vec3 > > ) {
395
+ self . fbb_ . push_slot_always :: < flatbuffers:: WIPOffset < _ > > ( Monster :: VT_PATH , path) ;
396
+ }
397
+ #[ inline]
382
398
pub fn new ( _fbb : & ' b mut flatbuffers:: FlatBufferBuilder < ' a > ) -> MonsterBuilder < ' a , ' b > {
383
399
let start = _fbb. start_table ( ) ;
384
400
MonsterBuilder {
@@ -431,11 +447,11 @@ impl<'a> Weapon<'a> {
431
447
pub const VT_DAMAGE : flatbuffers:: VOffsetT = 6 ;
432
448
433
449
#[ inline]
434
- pub fn name ( & ' a self ) -> Option < & ' a str > {
450
+ pub fn name ( & self ) -> Option < & ' a str > {
435
451
self . _tab . get :: < flatbuffers:: ForwardsUOffset < & str > > ( Weapon :: VT_NAME , None )
436
452
}
437
453
#[ inline]
438
- pub fn damage ( & ' a self ) -> i16 {
454
+ pub fn damage ( & self ) -> i16 {
439
455
self . _tab . get :: < i16 > ( Weapon :: VT_DAMAGE , Some ( 0 ) ) . unwrap ( )
440
456
}
441
457
}
0 commit comments