mycelium_bitfield/example/
example_bitfield.rs

1use crate::{
2    bitfield,
3    example::{AnotherTestEnum, TestEnum},
4};
5
6bitfield! {
7    /// An example bitfield type.
8    ///
9    /// This type was generated by the following [`bitfield!`]
10    /// macro invocation:
11    /// ```
12    #[doc = include_str!("example_bitfield.rs")]
13    /// ```
14    #[derive(PartialEq, Eq, Hash)]
15    pub struct ExampleBitfield<u64> {
16        /// Six bits of arbitrary meaning.
17        pub const SOME_BITS = 6;
18
19        /// A bit flag.
20        ///
21        /// This is `true` if foo is enabled. What that means is left
22        /// as an exercise to the reader.
23        pub const FOO_ENABLED: bool;
24
25        /// Another bit flag.
26        ///
27        /// This is `true` if bar is enabled. What that means is left
28        /// as an exercise to the reader.
29        pub const BAR_ENABLED: bool;
30
31        /// These bits are reserved and should always be 0.
32        const _RESERVED_1 = 2;
33
34        /// An enum value
35        pub const TEST_ENUM: TestEnum;
36
37        const _RESERVED_BITS = 4;
38
39        /// Another enum.
40        pub const ANOTHER_ENUM: AnotherTestEnum;
41
42        /// An 8-bit signed integer value.
43        ///
44        /// Who knows what this means.
45        pub const A_BYTE: i8;
46
47        /// `..` can be used to create a packing spec for all the remaining
48        /// bits in a bitfield.
49        pub const REST = ..;
50    }
51}