Trait nbits_vec::value::Value [] [src]

pub trait Value {
    type Block: PrimInt + One + Zero + LowerHex + Hash;
    fn nbits() -> usize;

    fn one() -> Self::Block { ... }
    fn zero() -> Self::Block { ... }
    fn mask() -> Self::Block { ... }
    fn block_bits() -> usize { ... }
    fn is_aligned() -> bool { ... }
    fn is_packed() -> bool { ... }
}

Associated Types

type Block: PrimInt + One + Zero + LowerHex + Hash

The storage type of Values.

The Block should be one of the primitive integer ie. u8, u16 u32, u64. Recommend that not to use usize because it is platform dependent.

Required Methods

fn nbits() -> usize

The value bit width.

Provided Methods

fn one() -> Self::Block

Return 1

fn zero() -> Self::Block

Return 0

fn mask() -> Self::Block

The value's bit mask in the Block.

For example, 2-bit value mask is 0b11, 3-bit mask is 0b111.

fn block_bits() -> usize

Bit-size of Block.

fn is_aligned() -> bool

Value is aligned when block_bits is divisible by nbits.

fn is_packed() -> bool

Value is packed when block_bits is equal to nbits.

Implementors