[][src]Trait modular_bitfield::Specifier

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>>; }

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.

Associated Types

type Bytes

The base type of the specifier.

Note

This is the type that is used internally for computations.

type InOut

The interface type of the specifier.

Note

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

Loading content...

Associated Constants

const BITS: usize

The amount of bits used by the specifier.

Loading content...

Required methods

fn into_bytes(input: Self::InOut) -> Result<Self::Bytes, OutOfBounds>

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.

fn from_bytes(
    bytes: Self::Bytes
) -> Result<Self::InOut, InvalidBitPattern<Self::Bytes>>

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.

Loading content...

Implementors

impl Specifier for B1[src]

type Bytes = u8

type InOut = u8

impl Specifier for B2[src]

type Bytes = u8

type InOut = u8

impl Specifier for B3[src]

type Bytes = u8

type InOut = u8

impl Specifier for B4[src]

type Bytes = u8

type InOut = u8

impl Specifier for B5[src]

type Bytes = u8

type InOut = u8

impl Specifier for B6[src]

type Bytes = u8

type InOut = u8

impl Specifier for B7[src]

type Bytes = u8

type InOut = u8

impl Specifier for B8[src]

type Bytes = u8

type InOut = u8

impl Specifier for B9[src]

type Bytes = u16

type InOut = u16

impl Specifier for B10[src]

type Bytes = u16

type InOut = u16

impl Specifier for B11[src]

type Bytes = u16

type InOut = u16

impl Specifier for B12[src]

type Bytes = u16

type InOut = u16

impl Specifier for B13[src]

type Bytes = u16

type InOut = u16

impl Specifier for B14[src]

type Bytes = u16

type InOut = u16

impl Specifier for B15[src]

type Bytes = u16

type InOut = u16

impl Specifier for B16[src]

type Bytes = u16

type InOut = u16

impl Specifier for B17[src]

type Bytes = u32

type InOut = u32

impl Specifier for B18[src]

type Bytes = u32

type InOut = u32

impl Specifier for B19[src]

type Bytes = u32

type InOut = u32

impl Specifier for B20[src]

type Bytes = u32

type InOut = u32

impl Specifier for B21[src]

type Bytes = u32

type InOut = u32

impl Specifier for B22[src]

type Bytes = u32

type InOut = u32

impl Specifier for B23[src]

type Bytes = u32

type InOut = u32

impl Specifier for B24[src]

type Bytes = u32

type InOut = u32

impl Specifier for B25[src]

type Bytes = u32

type InOut = u32

impl Specifier for B26[src]

type Bytes = u32

type InOut = u32

impl Specifier for B27[src]

type Bytes = u32

type InOut = u32

impl Specifier for B28[src]

type Bytes = u32

type InOut = u32

impl Specifier for B29[src]

type Bytes = u32

type InOut = u32

impl Specifier for B30[src]

type Bytes = u32

type InOut = u32

impl Specifier for B31[src]

type Bytes = u32

type InOut = u32

impl Specifier for B32[src]

type Bytes = u32

type InOut = u32

impl Specifier for B33[src]

type Bytes = u64

type InOut = u64

impl Specifier for B34[src]

type Bytes = u64

type InOut = u64

impl Specifier for B35[src]

type Bytes = u64

type InOut = u64

impl Specifier for B36[src]

type Bytes = u64

type InOut = u64

impl Specifier for B37[src]

type Bytes = u64

type InOut = u64

impl Specifier for B38[src]

type Bytes = u64

type InOut = u64

impl Specifier for B39[src]

type Bytes = u64

type InOut = u64

impl Specifier for B40[src]

type Bytes = u64

type InOut = u64

impl Specifier for B41[src]

type Bytes = u64

type InOut = u64

impl Specifier for B42[src]

type Bytes = u64

type InOut = u64

impl Specifier for B43[src]

type Bytes = u64

type InOut = u64

impl Specifier for B44[src]

type Bytes = u64

type InOut = u64

impl Specifier for B45[src]

type Bytes = u64

type InOut = u64

impl Specifier for B46[src]

type Bytes = u64

type InOut = u64

impl Specifier for B47[src]

type Bytes = u64

type InOut = u64

impl Specifier for B48[src]

type Bytes = u64

type InOut = u64

impl Specifier for B49[src]

type Bytes = u64

type InOut = u64

impl Specifier for B50[src]

type Bytes = u64

type InOut = u64

impl Specifier for B51[src]

type Bytes = u64

type InOut = u64

impl Specifier for B52[src]

type Bytes = u64

type InOut = u64

impl Specifier for B53[src]

type Bytes = u64

type InOut = u64

impl Specifier for B54[src]

type Bytes = u64

type InOut = u64

impl Specifier for B55[src]

type Bytes = u64

type InOut = u64

impl Specifier for B56[src]

type Bytes = u64

type InOut = u64

impl Specifier for B57[src]

type Bytes = u64

type InOut = u64

impl Specifier for B58[src]

type Bytes = u64

type InOut = u64

impl Specifier for B59[src]

type Bytes = u64

type InOut = u64

impl Specifier for B60[src]

type Bytes = u64

type InOut = u64

impl Specifier for B61[src]

type Bytes = u64

type InOut = u64

impl Specifier for B62[src]

type Bytes = u64

type InOut = u64

impl Specifier for B63[src]

type Bytes = u64

type InOut = u64

impl Specifier for B64[src]

type Bytes = u64

type InOut = u64

impl Specifier for B65[src]

type Bytes = u128

type InOut = u128

impl Specifier for B66[src]

type Bytes = u128

type InOut = u128

impl Specifier for B67[src]

type Bytes = u128

type InOut = u128

impl Specifier for B68[src]

type Bytes = u128

type InOut = u128

impl Specifier for B69[src]

type Bytes = u128

type InOut = u128

impl Specifier for B70[src]

type Bytes = u128

type InOut = u128

impl Specifier for B71[src]

type Bytes = u128

type InOut = u128

impl Specifier for B72[src]

type Bytes = u128

type InOut = u128

impl Specifier for B73[src]

type Bytes = u128

type InOut = u128

impl Specifier for B74[src]

type Bytes = u128

type InOut = u128

impl Specifier for B75[src]

type Bytes = u128

type InOut = u128

impl Specifier for B76[src]

type Bytes = u128

type InOut = u128

impl Specifier for B77[src]

type Bytes = u128

type InOut = u128

impl Specifier for B78[src]

type Bytes = u128

type InOut = u128

impl Specifier for B79[src]

type Bytes = u128

type InOut = u128

impl Specifier for B80[src]

type Bytes = u128

type InOut = u128

impl Specifier for B81[src]

type Bytes = u128

type InOut = u128

impl Specifier for B82[src]

type Bytes = u128

type InOut = u128

impl Specifier for B83[src]

type Bytes = u128

type InOut = u128

impl Specifier for B84[src]

type Bytes = u128

type InOut = u128

impl Specifier for B85[src]

type Bytes = u128

type InOut = u128

impl Specifier for B86[src]

type Bytes = u128

type InOut = u128

impl Specifier for B87[src]

type Bytes = u128

type InOut = u128

impl Specifier for B88[src]

type Bytes = u128

type InOut = u128

impl Specifier for B89[src]

type Bytes = u128

type InOut = u128

impl Specifier for B90[src]

type Bytes = u128

type InOut = u128

impl Specifier for B91[src]

type Bytes = u128

type InOut = u128

impl Specifier for B92[src]

type Bytes = u128

type InOut = u128

impl Specifier for B93[src]

type Bytes = u128

type InOut = u128

impl Specifier for B94[src]

type Bytes = u128

type InOut = u128

impl Specifier for B95[src]

type Bytes = u128

type InOut = u128

impl Specifier for B96[src]

type Bytes = u128

type InOut = u128

impl Specifier for B97[src]

type Bytes = u128

type InOut = u128

impl Specifier for B98[src]

type Bytes = u128

type InOut = u128

impl Specifier for B99[src]

type Bytes = u128

type InOut = u128

impl Specifier for B100[src]

type Bytes = u128

type InOut = u128

impl Specifier for B101[src]

type Bytes = u128

type InOut = u128

impl Specifier for B102[src]

type Bytes = u128

type InOut = u128

impl Specifier for B103[src]

type Bytes = u128

type InOut = u128

impl Specifier for B104[src]

type Bytes = u128

type InOut = u128

impl Specifier for B105[src]

type Bytes = u128

type InOut = u128

impl Specifier for B106[src]

type Bytes = u128

type InOut = u128

impl Specifier for B107[src]

type Bytes = u128

type InOut = u128

impl Specifier for B108[src]

type Bytes = u128

type InOut = u128

impl Specifier for B109[src]

type Bytes = u128

type InOut = u128

impl Specifier for B110[src]

type Bytes = u128

type InOut = u128

impl Specifier for B111[src]

type Bytes = u128

type InOut = u128

impl Specifier for B112[src]

type Bytes = u128

type InOut = u128

impl Specifier for B113[src]

type Bytes = u128

type InOut = u128

impl Specifier for B114[src]

type Bytes = u128

type InOut = u128

impl Specifier for B115[src]

type Bytes = u128

type InOut = u128

impl Specifier for B116[src]

type Bytes = u128

type InOut = u128

impl Specifier for B117[src]

type Bytes = u128

type InOut = u128

impl Specifier for B118[src]

type Bytes = u128

type InOut = u128

impl Specifier for B119[src]

type Bytes = u128

type InOut = u128

impl Specifier for B120[src]

type Bytes = u128

type InOut = u128

impl Specifier for B121[src]

type Bytes = u128

type InOut = u128

impl Specifier for B122[src]

type Bytes = u128

type InOut = u128

impl Specifier for B123[src]

type Bytes = u128

type InOut = u128

impl Specifier for B124[src]

type Bytes = u128

type InOut = u128

impl Specifier for B125[src]

type Bytes = u128

type InOut = u128

impl Specifier for B126[src]

type Bytes = u128

type InOut = u128

impl Specifier for B127[src]

type Bytes = u128

type InOut = u128

impl Specifier for B128[src]

type Bytes = u128

type InOut = u128

impl Specifier for bool[src]

type Bytes = u8

type InOut = bool

impl Specifier for u8[src]

type Bytes = u8

type InOut = u8

impl Specifier for u16[src]

type Bytes = u16

type InOut = u16

impl Specifier for u32[src]

type Bytes = u32

type InOut = u32

impl Specifier for u64[src]

type Bytes = u64

type InOut = u64

impl Specifier for u128[src]

type Bytes = u128

type InOut = u128

Loading content...