1use bitflags::bitflags;
9use zerocopy::{FromBytes, Immutable, IntoBytes, TryFromBytes};
10
11#[repr(C)]
12#[derive(Clone, Copy, Debug, Eq, FromBytes, Immutable, IntoBytes, PartialEq)]
13pub struct Empty {}
14
15#[repr(C)]
16#[derive(Clone, Copy, Debug, Eq, FromBytes, Immutable, IntoBytes, PartialEq)]
17pub struct Singleton {
18 pub value: u8,
19}
20
21#[repr(C)]
22#[derive(Clone, Copy, Debug, Eq, FromBytes, Immutable, IntoBytes, PartialEq)]
23pub struct Doubtleton {
24 pub first: Singleton,
25 pub second: Singleton,
26}
27
28#[repr(C)]
29#[derive(Clone, Copy, Debug, Eq, Immutable, 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, Immutable, 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, Immutable, 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(
78 Immutable, IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash,
79)]
80pub struct Bits(u16);
81
82bitflags! {
83 impl Bits : u16 {
84 const ONE = 1 << 0;
85 const TWO = 1 << 1;
86 }
87}
88
89#[repr(C)]
90#[derive(Clone, Copy, Debug, Eq, Immutable, PartialEq, TryFromBytes)]
91pub struct EnumAndBitsMembers {
92 pub e: Enum,
93 pub b: Bits,
94}
95
96#[repr(C)]
98#[derive(Clone, Copy, Debug, Eq, Immutable, PartialEq, TryFromBytes)]
99pub struct StructWithOneLineComment {
100 pub member_with_one_line_comment: u32,
102
103 pub member_with_many_line_comment: bool,
108}
109
110#[repr(C)]
116#[derive(Clone, Copy, Debug, Eq, FromBytes, Immutable, IntoBytes, PartialEq)]
117pub struct StructWithManyLineComment {
118 pub member: u16,
119}