1use bitflags::bitflags;
9use zerocopy::{FromBytes, IntoBytes};
10
11#[repr(C)]
12#[derive(IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
13pub struct Uint8Bits(u8);
14
15bitflags! {
16 impl Uint8Bits : u8 {
17 const ONE = 1 << 0;
18 const TWO = 1 << 1;
19 const FOUR = 1 << 2;
20 const EIGHT = 1 << 3;
21 const SIXTEEN = 1 << 4;
22 const THIRTY_TWO = 1 << 5;
23 const SIXTY_FOUR = 1 << 6;
24 const ONE_HUNDRED_TWENTY_EIGHT = 1 << 7;
25 }
26}
27
28#[repr(C)]
29#[derive(IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
30pub struct Uint16Bits(u16);
31
32bitflags! {
33 impl Uint16Bits : u16 {
34 const ZEROTH = 1 << 0;
35 const FIRST = 1 << 1;
36 const SECOND = 1 << 2;
37 const THIRD = 1 << 3;
38 const FOURTH = 1 << 4;
39 const FIFTH = 1 << 5;
40 const SIXTH = 1 << 6;
41 const SEVENTH = 1 << 7;
42 const EIGHT = 1 << 8;
43 const NINTH = 1 << 9;
44 const TENTH = 1 << 10;
45 const ELEVENTH = 1 << 11;
46 const TWELFTH = 1 << 12;
47 const THIRTEENTH = 1 << 13;
48 const FOURTEENTH = 1 << 14;
49 const FIFTHTEENTH = 1 << 15;
50 }
51}
52
53#[repr(C)]
54#[derive(IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
55pub struct Uint32Bits(u32);
56
57bitflags! {
58 impl Uint32Bits : u32 {
59 const POW_0 = 1 << 0;
60 const POW_31 = 1 << 31;
61 }
62}
63
64#[repr(C)]
65#[derive(IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
66pub struct Uint64Bits(u64);
67
68bitflags! {
69 impl Uint64Bits : u64 {
70 const POW_0 = 1 << 0;
71 const POW_63 = 1 << 63;
72 }
73}
74
75#[repr(C)]
77#[derive(IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
78pub struct BitsWithOneLineComment(u8);
79
80bitflags! {
81 impl BitsWithOneLineComment : u8 {
82
83 const MEMBER_WITH_ONE_LINE_COMMENT = 1 << 0;
85
86 const MEMBER_WITH_MANY_LINE_COMMENT = 1 << 6;
91 }
92}
93
94#[repr(C)]
100#[derive(IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
101pub struct BitsWithManyLineComment(u16);
102
103bitflags! {
104 impl BitsWithManyLineComment : u16 {
105 const MEMBER = 1 << 0;
106 }
107}
108
109pub const SEVENTY_TWO: Uint8Bits = Uint8Bits::from_bits_truncate(0b1001000); pub const SOME_BITS: Uint16Bits = Uint16Bits::from_bits_truncate(0b1001000000010); pub const U32_POW_0: Uint32Bits = Uint32Bits::POW_0;
114
115pub const U64_POW_63: Uint64Bits = Uint64Bits::POW_63;