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 #[allow(unused_imports, dead_code)] 12 pub mod namespace_a { 13 14 use std::mem; 15 use std::cmp::Ordering; 16 17 extern crate flatbuffers; 18 use self::flatbuffers::{EndianScalar, Follow}; 19 #[allow(unused_imports, dead_code)] 20 pub mod namespace_b { 21 22 use std::mem; 23 use std::cmp::Ordering; 24 25 extern crate flatbuffers; 26 use self::flatbuffers::{EndianScalar, Follow}; 27 28 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 29 pub const ENUM_MIN_UNION_IN_NESTED_NS: u8 = 0; 30 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 31 pub const ENUM_MAX_UNION_IN_NESTED_NS: u8 = 1; 32 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 33 #[allow(non_camel_case_types)] 34 pub const ENUM_VALUES_UNION_IN_NESTED_NS: [UnionInNestedNS; 2] = [ 35 UnionInNestedNS::NONE, 36 UnionInNestedNS::TableInNestedNS, 37 ]; 38 39 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 40 #[repr(transparent)] 41 pub struct UnionInNestedNS(pub u8); 42 #[allow(non_upper_case_globals)] 43 impl UnionInNestedNS { 44 pub const NONE: Self = Self(0); 45 pub const TableInNestedNS: Self = Self(1); 46 47 pub const ENUM_MIN: u8 = 0; 48 pub const ENUM_MAX: u8 = 1; 49 pub const ENUM_VALUES: &'static [Self] = &[ 50 Self::NONE, 51 Self::TableInNestedNS, 52 ]; 53 /// Returns the variant's name or "" if unknown. variant_name(self) -> Option<&'static str>54 pub fn variant_name(self) -> Option<&'static str> { 55 match self { 56 Self::NONE => Some("NONE"), 57 Self::TableInNestedNS => Some("TableInNestedNS"), 58 _ => None, 59 } 60 } 61 } 62 impl std::fmt::Debug for UnionInNestedNS { fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result63 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 64 if let Some(name) = self.variant_name() { 65 f.write_str(name) 66 } else { 67 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0)) 68 } 69 } 70 } 71 impl<'a> flatbuffers::Follow<'a> for UnionInNestedNS { 72 type Inner = Self; 73 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner74 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 75 let b = unsafe { 76 flatbuffers::read_scalar_at::<u8>(buf, loc) 77 }; 78 Self(b) 79 } 80 } 81 82 impl flatbuffers::Push for UnionInNestedNS { 83 type Output = UnionInNestedNS; 84 #[inline] push(&self, dst: &mut [u8], _rest: &[u8])85 fn push(&self, dst: &mut [u8], _rest: &[u8]) { 86 unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.0); } 87 } 88 } 89 90 impl flatbuffers::EndianScalar for UnionInNestedNS { 91 #[inline] to_little_endian(self) -> Self92 fn to_little_endian(self) -> Self { 93 let b = u8::to_le(self.0); 94 Self(b) 95 } 96 #[inline] 97 #[allow(clippy::wrong_self_convention)] from_little_endian(self) -> Self98 fn from_little_endian(self) -> Self { 99 let b = u8::from_le(self.0); 100 Self(b) 101 } 102 } 103 104 impl<'a> flatbuffers::Verifiable for UnionInNestedNS { 105 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>106 fn run_verifier( 107 v: &mut flatbuffers::Verifier, pos: usize 108 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 109 use self::flatbuffers::Verifiable; 110 u8::run_verifier(v, pos) 111 } 112 } 113 114 impl flatbuffers::SimpleToVerifyInSlice for UnionInNestedNS {} 115 pub struct UnionInNestedNSUnionTableOffset {} 116 117 #[non_exhaustive] 118 #[derive(Debug, Clone, PartialEq)] 119 pub enum UnionInNestedNST { 120 NONE, 121 TableInNestedNS(Box<TableInNestedNST>), 122 } 123 impl Default for UnionInNestedNST { default() -> Self124 fn default() -> Self { 125 Self::NONE 126 } 127 } 128 impl UnionInNestedNST { union_in_nested_ns_type(&self) -> UnionInNestedNS129 pub fn union_in_nested_ns_type(&self) -> UnionInNestedNS { 130 match self { 131 Self::NONE => UnionInNestedNS::NONE, 132 Self::TableInNestedNS(_) => UnionInNestedNS::TableInNestedNS, 133 } 134 } pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>135 pub fn pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> { 136 match self { 137 Self::NONE => None, 138 Self::TableInNestedNS(v) => Some(v.pack(fbb).as_union_value()), 139 } 140 } 141 /// If the union variant matches, return the owned TableInNestedNST, setting the union to NONE. take_table_in_nested_ns(&mut self) -> Option<Box<TableInNestedNST>>142 pub fn take_table_in_nested_ns(&mut self) -> Option<Box<TableInNestedNST>> { 143 if let Self::TableInNestedNS(_) = self { 144 let v = std::mem::replace(self, Self::NONE); 145 if let Self::TableInNestedNS(w) = v { 146 Some(w) 147 } else { 148 unreachable!() 149 } 150 } else { 151 None 152 } 153 } 154 /// If the union variant matches, return a reference to the TableInNestedNST. as_table_in_nested_ns(&self) -> Option<&TableInNestedNST>155 pub fn as_table_in_nested_ns(&self) -> Option<&TableInNestedNST> { 156 if let Self::TableInNestedNS(v) = self { Some(v.as_ref()) } else { None } 157 } 158 /// If the union variant matches, return a mutable reference to the TableInNestedNST. as_table_in_nested_ns_mut(&mut self) -> Option<&mut TableInNestedNST>159 pub fn as_table_in_nested_ns_mut(&mut self) -> Option<&mut TableInNestedNST> { 160 if let Self::TableInNestedNS(v) = self { Some(v.as_mut()) } else { None } 161 } 162 } 163 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 164 pub const ENUM_MIN_ENUM_IN_NESTED_NS: i8 = 0; 165 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 166 pub const ENUM_MAX_ENUM_IN_NESTED_NS: i8 = 2; 167 #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 168 #[allow(non_camel_case_types)] 169 pub const ENUM_VALUES_ENUM_IN_NESTED_NS: [EnumInNestedNS; 3] = [ 170 EnumInNestedNS::A, 171 EnumInNestedNS::B, 172 EnumInNestedNS::C, 173 ]; 174 175 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 176 #[repr(transparent)] 177 pub struct EnumInNestedNS(pub i8); 178 #[allow(non_upper_case_globals)] 179 impl EnumInNestedNS { 180 pub const A: Self = Self(0); 181 pub const B: Self = Self(1); 182 pub const C: Self = Self(2); 183 184 pub const ENUM_MIN: i8 = 0; 185 pub const ENUM_MAX: i8 = 2; 186 pub const ENUM_VALUES: &'static [Self] = &[ 187 Self::A, 188 Self::B, 189 Self::C, 190 ]; 191 /// Returns the variant's name or "" if unknown. variant_name(self) -> Option<&'static str>192 pub fn variant_name(self) -> Option<&'static str> { 193 match self { 194 Self::A => Some("A"), 195 Self::B => Some("B"), 196 Self::C => Some("C"), 197 _ => None, 198 } 199 } 200 } 201 impl std::fmt::Debug for EnumInNestedNS { fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result202 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 203 if let Some(name) = self.variant_name() { 204 f.write_str(name) 205 } else { 206 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0)) 207 } 208 } 209 } 210 impl<'a> flatbuffers::Follow<'a> for EnumInNestedNS { 211 type Inner = Self; 212 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner213 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 214 let b = unsafe { 215 flatbuffers::read_scalar_at::<i8>(buf, loc) 216 }; 217 Self(b) 218 } 219 } 220 221 impl flatbuffers::Push for EnumInNestedNS { 222 type Output = EnumInNestedNS; 223 #[inline] push(&self, dst: &mut [u8], _rest: &[u8])224 fn push(&self, dst: &mut [u8], _rest: &[u8]) { 225 unsafe { flatbuffers::emplace_scalar::<i8>(dst, self.0); } 226 } 227 } 228 229 impl flatbuffers::EndianScalar for EnumInNestedNS { 230 #[inline] to_little_endian(self) -> Self231 fn to_little_endian(self) -> Self { 232 let b = i8::to_le(self.0); 233 Self(b) 234 } 235 #[inline] 236 #[allow(clippy::wrong_self_convention)] from_little_endian(self) -> Self237 fn from_little_endian(self) -> Self { 238 let b = i8::from_le(self.0); 239 Self(b) 240 } 241 } 242 243 impl<'a> flatbuffers::Verifiable for EnumInNestedNS { 244 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>245 fn run_verifier( 246 v: &mut flatbuffers::Verifier, pos: usize 247 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 248 use self::flatbuffers::Verifiable; 249 i8::run_verifier(v, pos) 250 } 251 } 252 253 impl flatbuffers::SimpleToVerifyInSlice for EnumInNestedNS {} 254 // struct StructInNestedNS, aligned to 4 255 #[repr(transparent)] 256 #[derive(Clone, Copy, PartialEq)] 257 pub struct StructInNestedNS(pub [u8; 8]); 258 impl Default for StructInNestedNS { default() -> Self259 fn default() -> Self { 260 Self([0; 8]) 261 } 262 } 263 impl std::fmt::Debug for StructInNestedNS { fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result264 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 265 f.debug_struct("StructInNestedNS") 266 .field("a", &self.a()) 267 .field("b", &self.b()) 268 .finish() 269 } 270 } 271 272 impl flatbuffers::SimpleToVerifyInSlice for StructInNestedNS {} 273 impl flatbuffers::SafeSliceAccess for StructInNestedNS {} 274 impl<'a> flatbuffers::Follow<'a> for StructInNestedNS { 275 type Inner = &'a StructInNestedNS; 276 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner277 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 278 <&'a StructInNestedNS>::follow(buf, loc) 279 } 280 } 281 impl<'a> flatbuffers::Follow<'a> for &'a StructInNestedNS { 282 type Inner = &'a StructInNestedNS; 283 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner284 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 285 flatbuffers::follow_cast_ref::<StructInNestedNS>(buf, loc) 286 } 287 } 288 impl<'b> flatbuffers::Push for StructInNestedNS { 289 type Output = StructInNestedNS; 290 #[inline] push(&self, dst: &mut [u8], _rest: &[u8])291 fn push(&self, dst: &mut [u8], _rest: &[u8]) { 292 let src = unsafe { 293 ::std::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, Self::size()) 294 }; 295 dst.copy_from_slice(src); 296 } 297 } 298 impl<'b> flatbuffers::Push for &'b StructInNestedNS { 299 type Output = StructInNestedNS; 300 301 #[inline] push(&self, dst: &mut [u8], _rest: &[u8])302 fn push(&self, dst: &mut [u8], _rest: &[u8]) { 303 let src = unsafe { 304 ::std::slice::from_raw_parts(*self as *const StructInNestedNS as *const u8, Self::size()) 305 }; 306 dst.copy_from_slice(src); 307 } 308 } 309 310 impl<'a> flatbuffers::Verifiable for StructInNestedNS { 311 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>312 fn run_verifier( 313 v: &mut flatbuffers::Verifier, pos: usize 314 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 315 use self::flatbuffers::Verifiable; 316 v.in_buffer::<Self>(pos) 317 } 318 } 319 impl<'a> StructInNestedNS { 320 #[allow(clippy::too_many_arguments)] new( a: i32, b: i32, ) -> Self321 pub fn new( 322 a: i32, 323 b: i32, 324 ) -> Self { 325 let mut s = Self([0; 8]); 326 s.set_a(a); 327 s.set_b(b); 328 s 329 } 330 get_fully_qualified_name() -> &'static str331 pub const fn get_fully_qualified_name() -> &'static str { 332 "NamespaceA.NamespaceB.StructInNestedNS" 333 } 334 a(&self) -> i32335 pub fn a(&self) -> i32 { 336 let mut mem = core::mem::MaybeUninit::<i32>::uninit(); 337 unsafe { 338 core::ptr::copy_nonoverlapping( 339 self.0[0..].as_ptr(), 340 mem.as_mut_ptr() as *mut u8, 341 core::mem::size_of::<i32>(), 342 ); 343 mem.assume_init() 344 }.from_little_endian() 345 } 346 set_a(&mut self, x: i32)347 pub fn set_a(&mut self, x: i32) { 348 let x_le = x.to_little_endian(); 349 unsafe { 350 core::ptr::copy_nonoverlapping( 351 &x_le as *const i32 as *const u8, 352 self.0[0..].as_mut_ptr(), 353 core::mem::size_of::<i32>(), 354 ); 355 } 356 } 357 b(&self) -> i32358 pub fn b(&self) -> i32 { 359 let mut mem = core::mem::MaybeUninit::<i32>::uninit(); 360 unsafe { 361 core::ptr::copy_nonoverlapping( 362 self.0[4..].as_ptr(), 363 mem.as_mut_ptr() as *mut u8, 364 core::mem::size_of::<i32>(), 365 ); 366 mem.assume_init() 367 }.from_little_endian() 368 } 369 set_b(&mut self, x: i32)370 pub fn set_b(&mut self, x: i32) { 371 let x_le = x.to_little_endian(); 372 unsafe { 373 core::ptr::copy_nonoverlapping( 374 &x_le as *const i32 as *const u8, 375 self.0[4..].as_mut_ptr(), 376 core::mem::size_of::<i32>(), 377 ); 378 } 379 } 380 unpack(&self) -> StructInNestedNST381 pub fn unpack(&self) -> StructInNestedNST { 382 StructInNestedNST { 383 a: self.a(), 384 b: self.b(), 385 } 386 } 387 } 388 389 #[derive(Debug, Clone, PartialEq, Default)] 390 pub struct StructInNestedNST { 391 pub a: i32, 392 pub b: i32, 393 } 394 impl StructInNestedNST { pack(&self) -> StructInNestedNS395 pub fn pack(&self) -> StructInNestedNS { 396 StructInNestedNS::new( 397 self.a, 398 self.b, 399 ) 400 } 401 } 402 403 pub enum TableInNestedNSOffset {} 404 #[derive(Copy, Clone, PartialEq)] 405 406 pub struct TableInNestedNS<'a> { 407 pub _tab: flatbuffers::Table<'a>, 408 } 409 410 impl<'a> flatbuffers::Follow<'a> for TableInNestedNS<'a> { 411 type Inner = TableInNestedNS<'a>; 412 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner413 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 414 Self { _tab: flatbuffers::Table { buf, loc } } 415 } 416 } 417 418 impl<'a> TableInNestedNS<'a> { get_fully_qualified_name() -> &'static str419 pub const fn get_fully_qualified_name() -> &'static str { 420 "NamespaceA.NamespaceB.TableInNestedNS" 421 } 422 423 #[inline] init_from_table(table: flatbuffers::Table<'a>) -> Self424 pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 425 TableInNestedNS { _tab: table } 426 } 427 #[allow(unused_mut)] create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, args: &'args TableInNestedNSArgs) -> flatbuffers::WIPOffset<TableInNestedNS<'bldr>>428 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( 429 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, 430 args: &'args TableInNestedNSArgs) -> flatbuffers::WIPOffset<TableInNestedNS<'bldr>> { 431 let mut builder = TableInNestedNSBuilder::new(_fbb); 432 builder.add_foo(args.foo); 433 builder.finish() 434 } 435 unpack(&self) -> TableInNestedNST436 pub fn unpack(&self) -> TableInNestedNST { 437 let foo = self.foo(); 438 TableInNestedNST { 439 foo, 440 } 441 } 442 pub const VT_FOO: flatbuffers::VOffsetT = 4; 443 444 #[inline] foo(&self) -> i32445 pub fn foo(&self) -> i32 { 446 self._tab.get::<i32>(TableInNestedNS::VT_FOO, Some(0)).unwrap() 447 } 448 } 449 450 impl flatbuffers::Verifiable for TableInNestedNS<'_> { 451 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>452 fn run_verifier( 453 v: &mut flatbuffers::Verifier, pos: usize 454 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 455 use self::flatbuffers::Verifiable; 456 v.visit_table(pos)? 457 .visit_field::<i32>(&"foo", Self::VT_FOO, false)? 458 .finish(); 459 Ok(()) 460 } 461 } 462 pub struct TableInNestedNSArgs { 463 pub foo: i32, 464 } 465 impl<'a> Default for TableInNestedNSArgs { 466 #[inline] default() -> Self467 fn default() -> Self { 468 TableInNestedNSArgs { 469 foo: 0, 470 } 471 } 472 } 473 pub struct TableInNestedNSBuilder<'a: 'b, 'b> { 474 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, 475 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>, 476 } 477 impl<'a: 'b, 'b> TableInNestedNSBuilder<'a, 'b> { 478 #[inline] add_foo(&mut self, foo: i32)479 pub fn add_foo(&mut self, foo: i32) { 480 self.fbb_.push_slot::<i32>(TableInNestedNS::VT_FOO, foo, 0); 481 } 482 #[inline] new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TableInNestedNSBuilder<'a, 'b>483 pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TableInNestedNSBuilder<'a, 'b> { 484 let start = _fbb.start_table(); 485 TableInNestedNSBuilder { 486 fbb_: _fbb, 487 start_: start, 488 } 489 } 490 #[inline] finish(self) -> flatbuffers::WIPOffset<TableInNestedNS<'a>>491 pub fn finish(self) -> flatbuffers::WIPOffset<TableInNestedNS<'a>> { 492 let o = self.fbb_.end_table(self.start_); 493 flatbuffers::WIPOffset::new(o.value()) 494 } 495 } 496 497 impl std::fmt::Debug for TableInNestedNS<'_> { fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result498 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 499 let mut ds = f.debug_struct("TableInNestedNS"); 500 ds.field("foo", &self.foo()); 501 ds.finish() 502 } 503 } 504 #[non_exhaustive] 505 #[derive(Debug, Clone, PartialEq)] 506 pub struct TableInNestedNST { 507 pub foo: i32, 508 } 509 impl Default for TableInNestedNST { default() -> Self510 fn default() -> Self { 511 Self { 512 foo: 0, 513 } 514 } 515 } 516 impl TableInNestedNST { pack<'b>( &self, _fbb: &mut flatbuffers::FlatBufferBuilder<'b> ) -> flatbuffers::WIPOffset<TableInNestedNS<'b>>517 pub fn pack<'b>( 518 &self, 519 _fbb: &mut flatbuffers::FlatBufferBuilder<'b> 520 ) -> flatbuffers::WIPOffset<TableInNestedNS<'b>> { 521 let foo = self.foo; 522 TableInNestedNS::create(_fbb, &TableInNestedNSArgs{ 523 foo, 524 }) 525 } 526 } 527 } // pub mod NamespaceB 528 } // pub mod NamespaceA 529 530