• 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 extern crate serde;
11 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
12 use self::flatbuffers::{EndianScalar, Follow};
13 use super::*;
14 // struct Ability, aligned to 4
15 #[repr(transparent)]
16 #[derive(Clone, Copy, PartialEq)]
17 pub struct Ability(pub [u8; 8]);
18 impl Default for Ability {
default() -> Self19   fn default() -> Self {
20     Self([0; 8])
21   }
22 }
23 impl core::fmt::Debug for Ability {
fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result24   fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
25     f.debug_struct("Ability")
26       .field("id", &self.id())
27       .field("distance", &self.distance())
28       .finish()
29   }
30 }
31 
32 impl flatbuffers::SimpleToVerifyInSlice for Ability {}
33 impl flatbuffers::SafeSliceAccess for Ability {}
34 impl<'a> flatbuffers::Follow<'a> for Ability {
35   type Inner = &'a Ability;
36   #[inline]
follow(buf: &'a [u8], loc: usize) -> Self::Inner37   fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
38     <&'a Ability>::follow(buf, loc)
39   }
40 }
41 impl<'a> flatbuffers::Follow<'a> for &'a Ability {
42   type Inner = &'a Ability;
43   #[inline]
follow(buf: &'a [u8], loc: usize) -> Self::Inner44   fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
45     flatbuffers::follow_cast_ref::<Ability>(buf, loc)
46   }
47 }
48 impl<'b> flatbuffers::Push for Ability {
49     type Output = Ability;
50     #[inline]
push(&self, dst: &mut [u8], _rest: &[u8])51     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
52         let src = unsafe {
53             ::core::slice::from_raw_parts(self as *const Ability as *const u8, Self::size())
54         };
55         dst.copy_from_slice(src);
56     }
57 }
58 impl<'b> flatbuffers::Push for &'b Ability {
59     type Output = Ability;
60 
61     #[inline]
push(&self, dst: &mut [u8], _rest: &[u8])62     fn push(&self, dst: &mut [u8], _rest: &[u8]) {
63         let src = unsafe {
64             ::core::slice::from_raw_parts(*self as *const Ability as *const u8, Self::size())
65         };
66         dst.copy_from_slice(src);
67     }
68 }
69 
70 impl<'a> flatbuffers::Verifiable for Ability {
71   #[inline]
run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>72   fn run_verifier(
73     v: &mut flatbuffers::Verifier, pos: usize
74   ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
75     use self::flatbuffers::Verifiable;
76     v.in_buffer::<Self>(pos)
77   }
78 }
79 
80 impl Serialize for Ability {
serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer,81   fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
82   where
83     S: Serializer,
84   {
85     let mut s = serializer.serialize_struct("Ability", 2)?;
86       s.serialize_field("id", &self.id())?;
87       s.serialize_field("distance", &self.distance())?;
88     s.end()
89   }
90 }
91 
92 impl<'a> Ability {
93   #[allow(clippy::too_many_arguments)]
new( id: u32, distance: u32, ) -> Self94   pub fn new(
95     id: u32,
96     distance: u32,
97   ) -> Self {
98     let mut s = Self([0; 8]);
99     s.set_id(id);
100     s.set_distance(distance);
101     s
102   }
103 
get_fully_qualified_name() -> &'static str104   pub const fn get_fully_qualified_name() -> &'static str {
105     "MyGame.Example.Ability"
106   }
107 
id(&self) -> u32108   pub fn id(&self) -> u32 {
109     let mut mem = core::mem::MaybeUninit::<u32>::uninit();
110     unsafe {
111       core::ptr::copy_nonoverlapping(
112         self.0[0..].as_ptr(),
113         mem.as_mut_ptr() as *mut u8,
114         core::mem::size_of::<u32>(),
115       );
116       mem.assume_init()
117     }.from_little_endian()
118   }
119 
set_id(&mut self, x: u32)120   pub fn set_id(&mut self, x: u32) {
121     let x_le = x.to_little_endian();
122     unsafe {
123       core::ptr::copy_nonoverlapping(
124         &x_le as *const u32 as *const u8,
125         self.0[0..].as_mut_ptr(),
126         core::mem::size_of::<u32>(),
127       );
128     }
129   }
130 
131   #[inline]
key_compare_less_than(&self, o: &Ability) -> bool132   pub fn key_compare_less_than(&self, o: &Ability) -> bool {
133     self.id() < o.id()
134   }
135 
136   #[inline]
key_compare_with_value(&self, val: u32) -> ::core::cmp::Ordering137   pub fn key_compare_with_value(&self, val: u32) -> ::core::cmp::Ordering {
138     let key = self.id();
139     key.cmp(&val)
140   }
distance(&self) -> u32141   pub fn distance(&self) -> u32 {
142     let mut mem = core::mem::MaybeUninit::<u32>::uninit();
143     unsafe {
144       core::ptr::copy_nonoverlapping(
145         self.0[4..].as_ptr(),
146         mem.as_mut_ptr() as *mut u8,
147         core::mem::size_of::<u32>(),
148       );
149       mem.assume_init()
150     }.from_little_endian()
151   }
152 
set_distance(&mut self, x: u32)153   pub fn set_distance(&mut self, x: u32) {
154     let x_le = x.to_little_endian();
155     unsafe {
156       core::ptr::copy_nonoverlapping(
157         &x_le as *const u32 as *const u8,
158         self.0[4..].as_mut_ptr(),
159         core::mem::size_of::<u32>(),
160       );
161     }
162   }
163 
unpack(&self) -> AbilityT164   pub fn unpack(&self) -> AbilityT {
165     AbilityT {
166       id: self.id(),
167       distance: self.distance(),
168     }
169   }
170 }
171 
172 #[derive(Debug, Clone, PartialEq, Default)]
173 pub struct AbilityT {
174   pub id: u32,
175   pub distance: u32,
176 }
177 impl AbilityT {
pack(&self) -> Ability178   pub fn pack(&self) -> Ability {
179     Ability::new(
180       self.id,
181       self.distance,
182     )
183   }
184 }
185 
186