pub trait Specifier {
    type Bytes;
    type InOut;

    const BITS: usize;

    fn into_bytes(input: Self::InOut) -> Result<Self::Bytes, OutOfBounds>;
    fn from_bytes(
        bytes: Self::Bytes
    ) -> Result<Self::InOut, InvalidBitPattern<Self::Bytes>>; }
Expand description

Trait implemented by all bitfield specifiers.

Should generally not be implemented directly by users but through the macros provided by the crate.

Note

These can be all unsigned fixed-size primitives, represented by B1, B2, ... B64 and enums that derive from BitfieldSpecifier.

Required Associated Types

The base type of the specifier.

Note

This is the type that is used internally for computations.

The interface type of the specifier.

Note

This is the type that is used for the getters and setters.

Required Associated Constants

The amount of bits used by the specifier.

Required Methods

Converts some bytes into the in-out type.

Errors

If the in-out type is out of bounds. This can for example happen if your in-out type is u8 (for B7) but you specified a value that is bigger or equal to 128 which exceeds the 7 bits.

Converts the given bytes into the in-out type.

Errors

If the given byte pattern is invalid for the in-out type. This can happen for example for enums that have a number of variants which is not equal to the power of two and therefore yields some invalid bit patterns.

Implementations on Foreign Types

Implementors