1
1
// automatically generated by the FlatBuffers compiler, do not modify
2
2
3
3
4
+
5
+ extern crate core;
6
+
7
+ use core:: mem;
8
+ use core:: cmp:: Ordering ;
9
+
10
+ extern crate flatbuffers;
11
+ use self :: flatbuffers:: EndianScalar ;
12
+
13
+ #[ allow( unused_imports, dead_code) ]
4
14
pub mod my_game {
5
- #![ allow( dead_code) ]
6
- #![ allow( unused_imports) ]
7
15
8
- use std:: mem;
9
- use std:: marker:: PhantomData ;
10
- use std:: cmp:: Ordering ;
16
+ extern crate core;
17
+
18
+ use core:: mem;
19
+ use core:: cmp:: Ordering ;
11
20
12
21
extern crate flatbuffers;
13
22
use self :: flatbuffers:: EndianScalar ;
23
+ #[ allow( unused_imports, dead_code) ]
14
24
pub mod sample {
15
- #![ allow( dead_code) ]
16
- #![ allow( unused_imports) ]
17
25
18
- use std:: mem;
19
- use std:: marker:: PhantomData ;
20
- use std:: cmp:: Ordering ;
26
+ extern crate core;
27
+
28
+ use core:: mem;
29
+ use core:: cmp:: Ordering ;
21
30
22
31
extern crate flatbuffers;
23
32
use self :: flatbuffers:: EndianScalar ;
24
33
25
34
#[ allow( non_camel_case_types) ]
26
35
#[ repr( i8 ) ]
27
- #[ derive( Clone , Copy , PartialEq , Debug ) ]
36
+ #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
28
37
pub enum Color {
29
38
Red = 0 ,
30
39
Green = 1 ,
31
- Blue = 2
40
+ Blue = 2 ,
41
+
32
42
}
33
43
34
44
const ENUM_MIN_COLOR : i8 = 0 ;
@@ -80,16 +90,17 @@ const ENUM_NAMES_COLOR:[&'static str; 3] = [
80
90
] ;
81
91
82
92
pub fn enum_name_color ( e : Color ) -> & ' static str {
83
- let index: usize = e as usize ;
84
- ENUM_NAMES_COLOR [ index]
93
+ let index = e as i8 ;
94
+ ENUM_NAMES_COLOR [ index as usize ]
85
95
}
86
96
87
97
#[ allow( non_camel_case_types) ]
88
98
#[ repr( u8 ) ]
89
- #[ derive( Clone , Copy , PartialEq , Debug ) ]
99
+ #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
90
100
pub enum Equipment {
91
101
NONE = 0 ,
92
- Weapon = 1
102
+ Weapon = 1 ,
103
+
93
104
}
94
105
95
106
const ENUM_MIN_EQUIPMENT : u8 = 0 ;
@@ -139,8 +150,8 @@ const ENUM_NAMES_EQUIPMENT:[&'static str; 2] = [
139
150
] ;
140
151
141
152
pub fn enum_name_equipment ( e : Equipment ) -> & ' static str {
142
- let index: usize = e as usize ;
143
- ENUM_NAMES_EQUIPMENT [ index]
153
+ let index = e as u8 ;
154
+ ENUM_NAMES_EQUIPMENT [ index as usize ]
144
155
}
145
156
146
157
pub struct EquipmentUnionTableOffset { }
@@ -158,7 +169,6 @@ impl<'a> flatbuffers::Follow<'a> for Vec3 {
158
169
#[ inline]
159
170
fn follow ( buf : & ' a [ u8 ] , loc : usize ) -> Self :: Inner {
160
171
<& ' a Vec3 >:: follow ( buf, loc)
161
- //flatbuffers::follow_cast_ref::<Vec3>(buf, loc)
162
172
}
163
173
}
164
174
impl < ' a > flatbuffers:: Follow < ' a > for & ' a Vec3 {
@@ -173,7 +183,7 @@ impl<'b> flatbuffers::Push for Vec3 {
173
183
#[ inline]
174
184
fn push ( & self , dst : & mut [ u8 ] , _rest : & [ u8 ] ) {
175
185
let src = unsafe {
176
- :: std :: slice:: from_raw_parts ( self as * const Vec3 as * const u8 , Self :: size ( ) )
186
+ :: core :: slice:: from_raw_parts ( self as * const Vec3 as * const u8 , Self :: size ( ) )
177
187
} ;
178
188
dst. copy_from_slice ( src) ;
179
189
}
@@ -184,7 +194,7 @@ impl<'b> flatbuffers::Push for &'b Vec3 {
184
194
#[ inline]
185
195
fn push ( & self , dst : & mut [ u8 ] , _rest : & [ u8 ] ) {
186
196
let src = unsafe {
187
- :: std :: slice:: from_raw_parts ( * self as * const Vec3 as * const u8 , Self :: size ( ) )
197
+ :: core :: slice:: from_raw_parts ( * self as * const Vec3 as * const u8 , Self :: size ( ) )
188
198
} ;
189
199
dst. copy_from_slice ( src) ;
190
200
}
@@ -240,6 +250,7 @@ impl<'a> Monster<'a> {
240
250
_fbb : & ' mut_bldr mut flatbuffers:: FlatBufferBuilder < ' bldr > ,
241
251
args : & ' args MonsterArgs < ' args > ) -> flatbuffers:: WIPOffset < Monster < ' bldr > > {
242
252
let mut builder = MonsterBuilder :: new ( _fbb) ;
253
+ if let Some ( x) = args. path { builder. add_path ( x) ; }
243
254
if let Some ( x) = args. equipped { builder. add_equipped ( x) ; }
244
255
if let Some ( x) = args. weapons { builder. add_weapons ( x) ; }
245
256
if let Some ( x) = args. inventory { builder. add_inventory ( x) ; }
@@ -261,46 +272,51 @@ impl<'a> Monster<'a> {
261
272
pub const VT_WEAPONS : flatbuffers:: VOffsetT = 18 ;
262
273
pub const VT_EQUIPPED_TYPE : flatbuffers:: VOffsetT = 20 ;
263
274
pub const VT_EQUIPPED : flatbuffers:: VOffsetT = 22 ;
275
+ pub const VT_PATH : flatbuffers:: VOffsetT = 24 ;
264
276
265
277
#[ inline]
266
- pub fn pos ( & ' a self ) -> Option < & ' a Vec3 > {
278
+ pub fn pos ( & self ) -> Option < & ' a Vec3 > {
267
279
self . _tab . get :: < Vec3 > ( Monster :: VT_POS , None )
268
280
}
269
281
#[ inline]
270
- pub fn mana ( & ' a self ) -> i16 {
282
+ pub fn mana ( & self ) -> i16 {
271
283
self . _tab . get :: < i16 > ( Monster :: VT_MANA , Some ( 150 ) ) . unwrap ( )
272
284
}
273
285
#[ inline]
274
- pub fn hp ( & ' a self ) -> i16 {
286
+ pub fn hp ( & self ) -> i16 {
275
287
self . _tab . get :: < i16 > ( Monster :: VT_HP , Some ( 100 ) ) . unwrap ( )
276
288
}
277
289
#[ inline]
278
- pub fn name ( & ' a self ) -> Option < & ' a str > {
290
+ pub fn name ( & self ) -> Option < & ' a str > {
279
291
self . _tab . get :: < flatbuffers:: ForwardsUOffset < & str > > ( Monster :: VT_NAME , None )
280
292
}
281
293
#[ inline]
282
- pub fn inventory ( & ' a self ) -> Option < & ' a [ u8 ] > {
294
+ pub fn inventory ( & self ) -> Option < & ' a [ u8 ] > {
283
295
self . _tab . get :: < flatbuffers:: ForwardsUOffset < flatbuffers:: Vector < ' a , u8 > > > ( Monster :: VT_INVENTORY , None ) . map ( |v| v. safe_slice ( ) )
284
296
}
285
297
#[ inline]
286
- pub fn color ( & ' a self ) -> Color {
298
+ pub fn color ( & self ) -> Color {
287
299
self . _tab . get :: < Color > ( Monster :: VT_COLOR , Some ( Color :: Blue ) ) . unwrap ( )
288
300
}
289
301
#[ inline]
290
- pub fn weapons ( & ' a self ) -> Option < flatbuffers:: Vector < flatbuffers:: ForwardsUOffset < Weapon < ' a > > > > {
302
+ pub fn weapons ( & self ) -> Option < flatbuffers:: Vector < ' a , flatbuffers:: ForwardsUOffset < Weapon < ' a > > > > {
291
303
self . _tab . get :: < flatbuffers:: ForwardsUOffset < flatbuffers:: Vector < flatbuffers:: ForwardsUOffset < Weapon < ' a > > > > > ( Monster :: VT_WEAPONS , None )
292
304
}
293
305
#[ inline]
294
- pub fn equipped_type ( & ' a self ) -> Equipment {
306
+ pub fn equipped_type ( & self ) -> Equipment {
295
307
self . _tab . get :: < Equipment > ( Monster :: VT_EQUIPPED_TYPE , Some ( Equipment :: NONE ) ) . unwrap ( )
296
308
}
297
309
#[ inline]
298
- pub fn equipped ( & ' a self ) -> Option < flatbuffers:: Table < ' a > > {
310
+ pub fn equipped ( & self ) -> Option < flatbuffers:: Table < ' a > > {
299
311
self . _tab . get :: < flatbuffers:: ForwardsUOffset < flatbuffers:: Table < ' a > > > ( Monster :: VT_EQUIPPED , None )
300
312
}
301
313
#[ inline]
314
+ pub fn path ( & self ) -> Option < & ' a [ Vec3 ] > {
315
+ self . _tab . get :: < flatbuffers:: ForwardsUOffset < flatbuffers:: Vector < Vec3 > > > ( Monster :: VT_PATH , None ) . map ( |v| v. safe_slice ( ) )
316
+ }
317
+ #[ inline]
302
318
#[ allow( non_snake_case) ]
303
- pub fn equipped_as_weapon ( & ' a self ) -> Option < Weapon > {
319
+ pub fn equipped_as_weapon ( & self ) -> Option < Weapon < ' a > > {
304
320
if self . equipped_type ( ) == Equipment :: Weapon {
305
321
self . equipped ( ) . map ( |u| Weapon :: init_from_table ( u) )
306
322
} else {
@@ -320,6 +336,7 @@ pub struct MonsterArgs<'a> {
320
336
pub weapons : Option < flatbuffers:: WIPOffset < flatbuffers:: Vector < ' a , flatbuffers:: ForwardsUOffset < Weapon < ' a > > > > > ,
321
337
pub equipped_type : Equipment ,
322
338
pub equipped : Option < flatbuffers:: WIPOffset < flatbuffers:: UnionWIPOffset > > ,
339
+ pub path : Option < flatbuffers:: WIPOffset < flatbuffers:: Vector < ' a , Vec3 > > > ,
323
340
}
324
341
impl < ' a > Default for MonsterArgs < ' a > {
325
342
#[ inline]
@@ -334,6 +351,7 @@ impl<'a> Default for MonsterArgs<'a> {
334
351
weapons : None ,
335
352
equipped_type : Equipment :: NONE ,
336
353
equipped : None ,
354
+ path : None ,
337
355
}
338
356
}
339
357
}
@@ -379,6 +397,10 @@ impl<'a: 'b, 'b> MonsterBuilder<'a, 'b> {
379
397
self . fbb_ . push_slot_always :: < flatbuffers:: WIPOffset < _ > > ( Monster :: VT_EQUIPPED , equipped) ;
380
398
}
381
399
#[ inline]
400
+ pub fn add_path ( & mut self , path : flatbuffers:: WIPOffset < flatbuffers:: Vector < ' b , Vec3 > > ) {
401
+ self . fbb_ . push_slot_always :: < flatbuffers:: WIPOffset < _ > > ( Monster :: VT_PATH , path) ;
402
+ }
403
+ #[ inline]
382
404
pub fn new ( _fbb : & ' b mut flatbuffers:: FlatBufferBuilder < ' a > ) -> MonsterBuilder < ' a , ' b > {
383
405
let start = _fbb. start_table ( ) ;
384
406
MonsterBuilder {
@@ -431,11 +453,11 @@ impl<'a> Weapon<'a> {
431
453
pub const VT_DAMAGE : flatbuffers:: VOffsetT = 6 ;
432
454
433
455
#[ inline]
434
- pub fn name ( & ' a self ) -> Option < & ' a str > {
456
+ pub fn name ( & self ) -> Option < & ' a str > {
435
457
self . _tab . get :: < flatbuffers:: ForwardsUOffset < & str > > ( Weapon :: VT_NAME , None )
436
458
}
437
459
#[ inline]
438
- pub fn damage ( & ' a self ) -> i16 {
460
+ pub fn damage ( & self ) -> i16 {
439
461
self . _tab . get :: < i16 > ( Weapon :: VT_DAMAGE , Some ( 0 ) ) . unwrap ( )
440
462
}
441
463
}
0 commit comments