#[bitfield]Expand description
Creates a bitfield for this struct.
The arguments first, have to begin with the integer type of the bitfield:
For example: #[bitfield(u64)].
It can contain the following additional parameters, like the debug argument
for disabling the Debug trait generation (#[bitfield(u64, debug = false)]).
Parameters of the bitfield attribute:
- the bitfield integer type (required)
reprspecifies the bitfield’s representation in memoryfromto specify a conversion function from repr to the bitfield’s integer typeintoto specify a conversion function from the bitfield’s integer type to reprnewto disable thenewfunction generationbinreadto enable theBinReadtrait generationbinwriteto enable theBinWritetrait generationbinrwto enable bothBinReadandBinWritetrait generationcloneto disable theClonetrait generationdebugto disable theDebugtrait generationdefmtto enable thedefmt::Formattrait generationdefaultto disable theDefaulttrait generationhashto generate theHashtraitorderto specify the bit order (Lsb, Msb)conversionto disable the generation ofinto_bitsandfrom_bits
For
new,clone,debug,defmtordefault, you can either use booleans (#[bitfield(u8, debug = false)]) or cfg attributes (#[bitfield(u8, debug = cfg(test))]) to enable/disable them.
Parameters of the bits attribute (for fields):
- the number of bits
accessto specify the access mode (RW, RO, WO, None)defaultto set a default valueintoto specify a conversion function from the field type to the bitfield typefromto specify a conversion function from the bitfield type to the field type