File: long_enum_generated.rs

package info (click to toggle)
flatbuffers 2.0.8%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,308 kB
  • sloc: cpp: 44,808; python: 6,544; cs: 4,852; java: 4,389; ansic: 1,615; php: 1,455; xml: 973; javascript: 938; sh: 806; makefile: 35
file content (79 lines) | stat: -rw-r--r-- 2,029 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;
extern crate flatbuffers;
use alloc::boxed::Box;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::mem;
use core::cmp::Ordering;
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
#[allow(non_upper_case_globals)]
mod bitflags_long_enum {
  flatbuffers::bitflags::bitflags! {
    #[derive(Default)]
    pub struct LongEnum: u64 {
      const LongOne = 2;
      const LongTwo = 4;
      const LongBig = 1099511627776;
    }
  }
}
pub use self::bitflags_long_enum::LongEnum;

impl Serialize for LongEnum {
  fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
  where
    S: Serializer,
  {
    serializer.serialize_u32(self.bits() as u32)
  }
}

impl<'a> flatbuffers::Follow<'a> for LongEnum {
  type Inner = Self;
  #[inline]
  fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    let b = unsafe {
      flatbuffers::read_scalar_at::<u64>(buf, loc)
    };
    unsafe { Self::from_bits_unchecked(b) }
  }
}

impl flatbuffers::Push for LongEnum {
    type Output = LongEnum;
    #[inline]
    fn push(&self, dst: &mut [u8], _rest: &[u8]) {
        unsafe { flatbuffers::emplace_scalar::<u64>(dst, self.bits()); }
    }
}

impl flatbuffers::EndianScalar for LongEnum {
  #[inline]
  fn to_little_endian(self) -> Self {
    let b = u64::to_le(self.bits());
    unsafe { Self::from_bits_unchecked(b) }
  }
  #[inline]
  #[allow(clippy::wrong_self_convention)]
  fn from_little_endian(self) -> Self {
    let b = u64::from_le(self.bits());
    unsafe { Self::from_bits_unchecked(b) }
  }
}

impl<'a> flatbuffers::Verifiable for LongEnum {
  #[inline]
  fn run_verifier(
    v: &mut flatbuffers::Verifier, pos: usize
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
    use self::flatbuffers::Verifiable;
    u64::run_verifier(v, pos)
  }
}

impl flatbuffers::SimpleToVerifyInSlice for LongEnum {}