1use bitflags::bitflags;
9use zerocopy::{FromBytes, IntoBytes, TryFromBytes};
10
11#[repr(C)]
12#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
13pub struct Empty {}
14
15#[repr(C)]
16#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
17pub struct Singleton {
18 pub value: u8,
19}
20
21#[repr(C)]
22#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
23pub struct Doubtleton {
24 pub first: Singleton,
25 pub second: Singleton,
26}
27
28#[repr(C)]
29#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromBytes)]
30pub struct PrimitiveMembers {
31 pub i64: i64,
32 pub u64: u64,
33 pub i32: i32,
34 pub u32: u32,
35 pub i16: i16,
36 pub u16: u16,
37 pub i8: i8,
38 pub u8: u8,
39 pub b: bool,
40}
41
42#[repr(C)]
43#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
44pub struct ArrayMembers {
45 pub u8s: [u8; 10],
46 pub singletons: [Singleton; 6],
47 pub nested_arrays1: [[u8; 10]; 20],
48 pub nested_arrays2: [[[i8; 1]; 2]; 3],
49}
50
51#[repr(i32)]
52#[derive(Clone, Copy, Debug, Eq, Hash, IntoBytes, PartialEq, TryFromBytes)]
53pub enum Enum {
54 Zero = 0,
55 One = 1,
56}
57
58impl Enum {
59 pub fn from_raw(raw: i32) -> Option<Self> {
60 match raw {
61 0 => Some(Self::Zero),
62
63 1 => Some(Self::One),
64
65 _ => None,
66 }
67 }
68}
69
70impl From<Enum> for i32 {
71 fn from(val: Enum) -> Self {
72 val as Self
73 }
74}
75
76#[repr(C)]
77#[derive(IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
78pub struct Bits(u16);
79
80bitflags! {
81 impl Bits : u16 {
82 const ONE = 1 << 0;
83 const TWO = 1 << 1;
84 }
85}
86
87#[repr(C)]
88#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromBytes)]
89pub struct EnumAndBitsMembers {
90 pub e: Enum,
91 pub b: Bits,
92}
93
94#[repr(C)]
96#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromBytes)]
97pub struct StructWithOneLineComment {
98 pub member_with_one_line_comment: u32,
100
101 pub member_with_many_line_comment: bool,
106}
107
108#[repr(C)]
114#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
115pub struct StructWithManyLineComment {
116 pub member: u16,
117}