• 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 use self::flatbuffers::{EndianScalar, Follow};
11 use super::*;
12 #[allow(non_upper_case_globals)]
13 mod bitflags_long_enum {
14   flatbuffers::bitflags::bitflags! {
15     #[derive(Default)]
16     pub struct LongEnum: u64 {
17       const LongOne = 2;
18       const LongTwo = 4;
19       const LongBig = 1099511627776;
20     }
21   }
22 }
23 pub use self::bitflags_long_enum::LongEnum;
24 
25 impl<'a> flatbuffers::Follow<'a> for LongEnum {
26   type Inner = Self;
27   #[inline]
follow(buf: &'a [u8], loc: usize) -> Self::Inner28   unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
29     let b = flatbuffers::read_scalar_at::<u64>(buf, loc);
30     // Safety:
31     // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size.
32     // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0
33     // https://github.com/bitflags/bitflags/issues/262
34     Self::from_bits_unchecked(b)
35   }
36 }
37 
38 impl flatbuffers::Push for LongEnum {
39     type Output = LongEnum;
40     #[inline]
push(&self, dst: &mut [u8], _written_len: usize)41     unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
42         flatbuffers::emplace_scalar::<u64>(dst, self.bits());
43     }
44 }
45 
46 impl flatbuffers::EndianScalar for LongEnum {
47   type Scalar = u64;
48   #[inline]
to_little_endian(self) -> u6449   fn to_little_endian(self) -> u64 {
50     self.bits().to_le()
51   }
52   #[inline]
53   #[allow(clippy::wrong_self_convention)]
from_little_endian(v: u64) -> Self54   fn from_little_endian(v: u64) -> Self {
55     let b = u64::from_le(v);
56     // Safety:
57     // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size.
58     // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0
59     // https://github.com/bitflags/bitflags/issues/262
60     unsafe { Self::from_bits_unchecked(b) }
61   }
62 }
63 
64 impl<'a> flatbuffers::Verifiable for LongEnum {
65   #[inline]
run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>66   fn run_verifier(
67     v: &mut flatbuffers::Verifier, pos: usize
68   ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
69     use self::flatbuffers::Verifiable;
70     u64::run_verifier(v, pos)
71   }
72 }
73 
74 impl flatbuffers::SimpleToVerifyInSlice for LongEnum {}
75