1 // automatically generated by the FlatBuffers compiler, do not modify 2 3 4 5 use std::mem; 6 use std::cmp::Ordering; 7 8 extern crate flatbuffers; 9 use self::flatbuffers::{EndianScalar, Follow}; 10 11 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 12 pub const ENUM_MIN_ABC: i32 = 0; 13 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 14 pub const ENUM_MAX_ABC: i32 = 2; 15 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 16 #[allow(non_camel_case_types)] 17 pub const ENUM_VALUES_ABC: [ABC; 3] = [ 18 ABC::A, 19 ABC::B, 20 ABC::C, 21 ]; 22 23 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 24 #[repr(transparent)] 25 pub struct ABC(pub i32); 26 #[allow(non_upper_case_globals)] 27 impl ABC { 28 pub const A: Self = Self(0); 29 pub const B: Self = Self(1); 30 pub const C: Self = Self(2); 31 32 pub const ENUM_MIN: i32 = 0; 33 pub const ENUM_MAX: i32 = 2; 34 pub const ENUM_VALUES: &'static [Self] = &[ 35 Self::A, 36 Self::B, 37 Self::C, 38 ]; 39 /// Returns the variant's name or "" if unknown. variant_name(self) -> Option<&'static str>40 pub fn variant_name(self) -> Option<&'static str> { 41 match self { 42 Self::A => Some("A"), 43 Self::B => Some("B"), 44 Self::C => Some("C"), 45 _ => None, 46 } 47 } 48 } 49 impl std::fmt::Debug for ABC { fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result50 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 51 if let Some(name) = self.variant_name() { 52 f.write_str(name) 53 } else { 54 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0)) 55 } 56 } 57 } 58 impl<'a> flatbuffers::Follow<'a> for ABC { 59 type Inner = Self; 60 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner61 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 62 let b = unsafe { 63 flatbuffers::read_scalar_at::<i32>(buf, loc) 64 }; 65 Self(b) 66 } 67 } 68 69 impl flatbuffers::Push for ABC { 70 type Output = ABC; 71 #[inline] push(&self, dst: &mut [u8], _rest: &[u8])72 fn push(&self, dst: &mut [u8], _rest: &[u8]) { 73 unsafe { flatbuffers::emplace_scalar::<i32>(dst, self.0); } 74 } 75 } 76 77 impl flatbuffers::EndianScalar for ABC { 78 #[inline] to_little_endian(self) -> Self79 fn to_little_endian(self) -> Self { 80 let b = i32::to_le(self.0); 81 Self(b) 82 } 83 #[inline] 84 #[allow(clippy::wrong_self_convention)] from_little_endian(self) -> Self85 fn from_little_endian(self) -> Self { 86 let b = i32::from_le(self.0); 87 Self(b) 88 } 89 } 90 91 impl<'a> flatbuffers::Verifiable for ABC { 92 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>93 fn run_verifier( 94 v: &mut flatbuffers::Verifier, pos: usize 95 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 96 use self::flatbuffers::Verifiable; 97 i32::run_verifier(v, pos) 98 } 99 } 100 101 impl flatbuffers::SimpleToVerifyInSlice for ABC {} 102 pub enum MoreDefaultsOffset {} 103 #[derive(Copy, Clone, PartialEq)] 104 105 pub struct MoreDefaults<'a> { 106 pub _tab: flatbuffers::Table<'a>, 107 } 108 109 impl<'a> flatbuffers::Follow<'a> for MoreDefaults<'a> { 110 type Inner = MoreDefaults<'a>; 111 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner112 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 113 Self { _tab: flatbuffers::Table { buf, loc } } 114 } 115 } 116 117 impl<'a> MoreDefaults<'a> { 118 #[inline] init_from_table(table: flatbuffers::Table<'a>) -> Self119 pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 120 MoreDefaults { _tab: table } 121 } 122 #[allow(unused_mut)] create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, args: &'args MoreDefaultsArgs<'args>) -> flatbuffers::WIPOffset<MoreDefaults<'bldr>>123 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( 124 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, 125 args: &'args MoreDefaultsArgs<'args>) -> flatbuffers::WIPOffset<MoreDefaults<'bldr>> { 126 let mut builder = MoreDefaultsBuilder::new(_fbb); 127 if let Some(x) = args.bools { builder.add_bools(x); } 128 if let Some(x) = args.abcs { builder.add_abcs(x); } 129 if let Some(x) = args.some_string { builder.add_some_string(x); } 130 if let Some(x) = args.empty_string { builder.add_empty_string(x); } 131 if let Some(x) = args.floats { builder.add_floats(x); } 132 if let Some(x) = args.ints { builder.add_ints(x); } 133 builder.finish() 134 } 135 unpack(&self) -> MoreDefaultsT136 pub fn unpack(&self) -> MoreDefaultsT { 137 let ints = { 138 let x = self.ints(); 139 x.into_iter().collect() 140 }; 141 let floats = { 142 let x = self.floats(); 143 x.into_iter().collect() 144 }; 145 let empty_string = { 146 let x = self.empty_string(); 147 x.to_string() 148 }; 149 let some_string = { 150 let x = self.some_string(); 151 x.to_string() 152 }; 153 let abcs = { 154 let x = self.abcs(); 155 x.into_iter().collect() 156 }; 157 let bools = { 158 let x = self.bools(); 159 x.to_vec() 160 }; 161 MoreDefaultsT { 162 ints, 163 floats, 164 empty_string, 165 some_string, 166 abcs, 167 bools, 168 } 169 } 170 pub const VT_INTS: flatbuffers::VOffsetT = 4; 171 pub const VT_FLOATS: flatbuffers::VOffsetT = 6; 172 pub const VT_EMPTY_STRING: flatbuffers::VOffsetT = 8; 173 pub const VT_SOME_STRING: flatbuffers::VOffsetT = 10; 174 pub const VT_ABCS: flatbuffers::VOffsetT = 12; 175 pub const VT_BOOLS: flatbuffers::VOffsetT = 14; 176 177 #[inline] ints(&self) -> flatbuffers::Vector<'a, i32>178 pub fn ints(&self) -> flatbuffers::Vector<'a, i32> { 179 self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i32>>>(MoreDefaults::VT_INTS, Some(Default::default())).unwrap() 180 } 181 #[inline] floats(&self) -> flatbuffers::Vector<'a, f32>182 pub fn floats(&self) -> flatbuffers::Vector<'a, f32> { 183 self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, f32>>>(MoreDefaults::VT_FLOATS, Some(Default::default())).unwrap() 184 } 185 #[inline] empty_string(&self) -> &'a str186 pub fn empty_string(&self) -> &'a str { 187 self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(MoreDefaults::VT_EMPTY_STRING, Some(&"")).unwrap() 188 } 189 #[inline] some_string(&self) -> &'a str190 pub fn some_string(&self) -> &'a str { 191 self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(MoreDefaults::VT_SOME_STRING, Some(&"some")).unwrap() 192 } 193 #[inline] abcs(&self) -> flatbuffers::Vector<'a, ABC>194 pub fn abcs(&self) -> flatbuffers::Vector<'a, ABC> { 195 self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, ABC>>>(MoreDefaults::VT_ABCS, Some(Default::default())).unwrap() 196 } 197 #[inline] bools(&self) -> &'a [bool]198 pub fn bools(&self) -> &'a [bool] { 199 self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, bool>>>(MoreDefaults::VT_BOOLS, Some(Default::default())).map(|v| v.safe_slice()).unwrap() 200 } 201 } 202 203 impl flatbuffers::Verifiable for MoreDefaults<'_> { 204 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>205 fn run_verifier( 206 v: &mut flatbuffers::Verifier, pos: usize 207 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 208 use self::flatbuffers::Verifiable; 209 v.visit_table(pos)? 210 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i32>>>(&"ints", Self::VT_INTS, false)? 211 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, f32>>>(&"floats", Self::VT_FLOATS, false)? 212 .visit_field::<flatbuffers::ForwardsUOffset<&str>>(&"empty_string", Self::VT_EMPTY_STRING, false)? 213 .visit_field::<flatbuffers::ForwardsUOffset<&str>>(&"some_string", Self::VT_SOME_STRING, false)? 214 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, ABC>>>(&"abcs", Self::VT_ABCS, false)? 215 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, bool>>>(&"bools", Self::VT_BOOLS, false)? 216 .finish(); 217 Ok(()) 218 } 219 } 220 pub struct MoreDefaultsArgs<'a> { 221 pub ints: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i32>>>, 222 pub floats: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, f32>>>, 223 pub empty_string: Option<flatbuffers::WIPOffset<&'a str>>, 224 pub some_string: Option<flatbuffers::WIPOffset<&'a str>>, 225 pub abcs: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, ABC>>>, 226 pub bools: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, bool>>>, 227 } 228 impl<'a> Default for MoreDefaultsArgs<'a> { 229 #[inline] default() -> Self230 fn default() -> Self { 231 MoreDefaultsArgs { 232 ints: None, 233 floats: None, 234 empty_string: None, 235 some_string: None, 236 abcs: None, 237 bools: None, 238 } 239 } 240 } 241 pub struct MoreDefaultsBuilder<'a: 'b, 'b> { 242 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, 243 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>, 244 } 245 impl<'a: 'b, 'b> MoreDefaultsBuilder<'a, 'b> { 246 #[inline] add_ints(&mut self, ints: flatbuffers::WIPOffset<flatbuffers::Vector<'b , i32>>)247 pub fn add_ints(&mut self, ints: flatbuffers::WIPOffset<flatbuffers::Vector<'b , i32>>) { 248 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(MoreDefaults::VT_INTS, ints); 249 } 250 #[inline] add_floats(&mut self, floats: flatbuffers::WIPOffset<flatbuffers::Vector<'b , f32>>)251 pub fn add_floats(&mut self, floats: flatbuffers::WIPOffset<flatbuffers::Vector<'b , f32>>) { 252 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(MoreDefaults::VT_FLOATS, floats); 253 } 254 #[inline] add_empty_string(&mut self, empty_string: flatbuffers::WIPOffset<&'b str>)255 pub fn add_empty_string(&mut self, empty_string: flatbuffers::WIPOffset<&'b str>) { 256 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(MoreDefaults::VT_EMPTY_STRING, empty_string); 257 } 258 #[inline] add_some_string(&mut self, some_string: flatbuffers::WIPOffset<&'b str>)259 pub fn add_some_string(&mut self, some_string: flatbuffers::WIPOffset<&'b str>) { 260 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(MoreDefaults::VT_SOME_STRING, some_string); 261 } 262 #[inline] add_abcs(&mut self, abcs: flatbuffers::WIPOffset<flatbuffers::Vector<'b , ABC>>)263 pub fn add_abcs(&mut self, abcs: flatbuffers::WIPOffset<flatbuffers::Vector<'b , ABC>>) { 264 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(MoreDefaults::VT_ABCS, abcs); 265 } 266 #[inline] add_bools(&mut self, bools: flatbuffers::WIPOffset<flatbuffers::Vector<'b , bool>>)267 pub fn add_bools(&mut self, bools: flatbuffers::WIPOffset<flatbuffers::Vector<'b , bool>>) { 268 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(MoreDefaults::VT_BOOLS, bools); 269 } 270 #[inline] new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MoreDefaultsBuilder<'a, 'b>271 pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MoreDefaultsBuilder<'a, 'b> { 272 let start = _fbb.start_table(); 273 MoreDefaultsBuilder { 274 fbb_: _fbb, 275 start_: start, 276 } 277 } 278 #[inline] finish(self) -> flatbuffers::WIPOffset<MoreDefaults<'a>>279 pub fn finish(self) -> flatbuffers::WIPOffset<MoreDefaults<'a>> { 280 let o = self.fbb_.end_table(self.start_); 281 flatbuffers::WIPOffset::new(o.value()) 282 } 283 } 284 285 impl std::fmt::Debug for MoreDefaults<'_> { fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result286 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 287 let mut ds = f.debug_struct("MoreDefaults"); 288 ds.field("ints", &self.ints()); 289 ds.field("floats", &self.floats()); 290 ds.field("empty_string", &self.empty_string()); 291 ds.field("some_string", &self.some_string()); 292 ds.field("abcs", &self.abcs()); 293 ds.field("bools", &self.bools()); 294 ds.finish() 295 } 296 } 297 #[non_exhaustive] 298 #[derive(Debug, Clone, PartialEq)] 299 pub struct MoreDefaultsT { 300 pub ints: Vec<i32>, 301 pub floats: Vec<f32>, 302 pub empty_string: String, 303 pub some_string: String, 304 pub abcs: Vec<ABC>, 305 pub bools: Vec<bool>, 306 } 307 impl Default for MoreDefaultsT { default() -> Self308 fn default() -> Self { 309 Self { 310 ints: Default::default(), 311 floats: Default::default(), 312 empty_string: "".to_string(), 313 some_string: "some".to_string(), 314 abcs: Default::default(), 315 bools: Default::default(), 316 } 317 } 318 } 319 impl MoreDefaultsT { pack<'b>( &self, _fbb: &mut flatbuffers::FlatBufferBuilder<'b> ) -> flatbuffers::WIPOffset<MoreDefaults<'b>>320 pub fn pack<'b>( 321 &self, 322 _fbb: &mut flatbuffers::FlatBufferBuilder<'b> 323 ) -> flatbuffers::WIPOffset<MoreDefaults<'b>> { 324 let ints = Some({ 325 let x = &self.ints; 326 _fbb.create_vector(x) 327 }); 328 let floats = Some({ 329 let x = &self.floats; 330 _fbb.create_vector(x) 331 }); 332 let empty_string = Some({ 333 let x = &self.empty_string; 334 _fbb.create_string(x) 335 }); 336 let some_string = Some({ 337 let x = &self.some_string; 338 _fbb.create_string(x) 339 }); 340 let abcs = Some({ 341 let x = &self.abcs; 342 _fbb.create_vector(x) 343 }); 344 let bools = Some({ 345 let x = &self.bools; 346 _fbb.create_vector(x) 347 }); 348 MoreDefaults::create(_fbb, &MoreDefaultsArgs{ 349 ints, 350 floats, 351 empty_string, 352 some_string, 353 abcs, 354 bools, 355 }) 356 } 357 } 358