Bitfield Struct
Procedural macro for bitfields that allows specifying bitfields as structs.
As this library provides a procedural-macro it has no runtime dependencies and works for no-std
.
Usage
Add this to your Cargo.toml
:
[]
= "0.1.6"
Example
The macro generates three accessor functions for each field. Each accessor also inherits the documentation of its field.
The signatures for addr
for example are:
;
This generated bitfield then can be used as follows.
let pte = new
.with_addr
.with_size
.with_present
.with_negative;
println!;
pte.set_size;
let value: u64 = pte.into;
println!;