pub trait BitAccess {
    fn get_bit(&self, bit_nr: usize) -> bool;
    fn set_bit(&mut self, bit_nr: usize);
    fn clear_bit(&mut self, bit_nr: usize);
    fn get_bits(&self, begin: usize, len: u8) -> u64;
    fn set_bits(&mut self, begin: usize, v: u64, len: u8);

    fn get_fragment(&self, index: usize, v_size: u8) -> u64 { ... }
    fn init_fragment(&mut self, index: usize, v: u64, v_size: u8) { ... }
    fn set_fragment(&mut self, index: usize, v: u64, v_size: u8) { ... }
    fn swap_fragments(&mut self, index1: usize, index2: usize, v_size: u8) { ... }
    fn conditionally_change_bits<NewValue>(
        &mut self,
        new_value: NewValue,
        begin: usize,
        v_size: u8
    ) -> u64
    where
        NewValue: FnOnce(u64) -> Option<u64>
, { ... } fn conditionally_change_fragment<NewValue>(
        &mut self,
        new_value: NewValue,
        index: usize,
        v_size: u8
    ) -> u64
    where
        NewValue: FnOnce(u64) -> Option<u64>
, { ... } }
Expand description

The trait that is implemented for the array of u64 and extends it with methods for accessing and modifying single bits or arbitrary fragments consisted of few (up to 63) bits.

Required methods

Gets bit with given index bit_nr.

Sets bit with given index bit_nr to 1.

Sets bit with given index bit_nr to 0.

Gets bits [begin, begin+len).

Sets bits [begin, begin+len) to the content of v.

Provided methods

Gets v_size bits with indices in range [index*v_size, index*v_size+v_size).

Inits v_size bits with indices in range [index*v_size, index*v_size+v_size) to v. Before init, the bits are assumed to be cleared or already set to v.

Sets v_size bits with indices in range [index*v_size, index*v_size+v_size) to v.

Swaps ranges of bits: [index1*v_size, index1*v_size+v_size) with [index2*v_size, index2*v_size+v_size).

Conditionally (if new_value does not return None) changes the value old stored at bits [begin, begin+v_size) to the one returned by new_value (whose argument is old). Returns old (the value before change).

Conditionally (if new_value does not return None) changes the value old stored at bits [index*v_size, index*v_size+v_size) to the one returned by new_value (whose argument is old). Returns old (the value before change).

Implementations on Foreign Types

Implementors