bitstring::utils

Trait BigEndianBitString

source
pub trait BigEndianBitString {
    // Required methods
    fn bits(&self) -> usize;
    fn bits_inc(&mut self, prefix: usize) -> bool;
    fn bit_get(&self, ndx: usize) -> bool;
    fn bit_set(&mut self, ndx: usize, bit: bool);
    fn bit_flip(&mut self, ndx: usize);
    fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize;
    fn set_false_from(&mut self, ndx: usize);
    fn is_false_from(&self, ndx: usize) -> bool;
    fn set_true_from(&mut self, ndx: usize);
    fn is_true_from(&self, ndx: usize) -> bool;
    fn bits_prefix_of(&self, prefix_len: usize, value: &Self) -> bool;
}
Available on crate feature bigendian only.
Expand description

Generic helper methods to treat unsigned integer and slices of them as big endian bit strings.

Required Methods§

source

fn bits(&self) -> usize

maximum number of bits in storage

source

fn bits_inc(&mut self, prefix: usize) -> bool

increment from right; don’t touch first prefix bits; returns true on overflow

§Panics

Panics if prefix > self.bits().

source

fn bit_get(&self, ndx: usize) -> bool

Get the ndxth bit.

§Panics

Panics if ndx >= Self::ELEMENT_BITS() * slice.len().

source

fn bit_set(&mut self, ndx: usize, bit: bool)

Set the ndxth bit to bit.

§Panics

Panics if ndx >= Self::ELEMENT_BITS() * slice.len().

source

fn bit_flip(&mut self, ndx: usize)

Flips the ndxth bit.

§Panics

Panics if ndx >= Self::ELEMENT_BITS() * slice.len().

source

fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize

Length of the longest shared prefix of two bit strings.

source

fn set_false_from(&mut self, ndx: usize)

Set all bits from [ndx..] to false (0).

Doesn’t do anything if ndx >= Self::ELEMENT_BITS() * slice.len().

source

fn is_false_from(&self, ndx: usize) -> bool

Whether all bits from [ndx..] are false (0).

Returns true if ndx >= Self::ELEMENT_BITS() * slice.len().

source

fn set_true_from(&mut self, ndx: usize)

Set all bits from [ndx..] to true (1).

Doesn’t do anything if ndx >= Self::ELEMENT_BITS() * slice.len().

source

fn is_true_from(&self, ndx: usize) -> bool

Whether all bits from [ndx..] are true (1).

Returns true if ndx >= Self::ELEMENT_BITS() * slice.len().

source

fn bits_prefix_of(&self, prefix_len: usize, value: &Self) -> bool

check whether another bit string value shares the first prefix_len bits with self

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl BigEndianBitString for u8

source§

fn bits(&self) -> usize

source§

fn bits_inc(&mut self, prefix: usize) -> bool

source§

fn bit_get(&self, ndx: usize) -> bool

source§

fn bit_set(&mut self, ndx: usize, bit: bool)

source§

fn bit_flip(&mut self, ndx: usize)

source§

fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize

source§

fn set_false_from(&mut self, ndx: usize)

source§

fn is_false_from(&self, ndx: usize) -> bool

source§

fn set_true_from(&mut self, ndx: usize)

source§

fn is_true_from(&self, ndx: usize) -> bool

source§

fn bits_prefix_of(&self, prefix: usize, other: &Self) -> bool

source§

impl BigEndianBitString for u16

source§

fn bits(&self) -> usize

source§

fn bits_inc(&mut self, prefix: usize) -> bool

source§

fn bit_get(&self, ndx: usize) -> bool

source§

fn bit_set(&mut self, ndx: usize, bit: bool)

source§

fn bit_flip(&mut self, ndx: usize)

source§

fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize

source§

fn set_false_from(&mut self, ndx: usize)

source§

fn is_false_from(&self, ndx: usize) -> bool

source§

fn set_true_from(&mut self, ndx: usize)

source§

fn is_true_from(&self, ndx: usize) -> bool

source§

fn bits_prefix_of(&self, prefix: usize, other: &Self) -> bool

source§

impl BigEndianBitString for u32

source§

fn bits(&self) -> usize

source§

fn bits_inc(&mut self, prefix: usize) -> bool

source§

fn bit_get(&self, ndx: usize) -> bool

source§

fn bit_set(&mut self, ndx: usize, bit: bool)

source§

fn bit_flip(&mut self, ndx: usize)

source§

fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize

source§

fn set_false_from(&mut self, ndx: usize)

source§

fn is_false_from(&self, ndx: usize) -> bool

source§

fn set_true_from(&mut self, ndx: usize)

source§

fn is_true_from(&self, ndx: usize) -> bool

source§

fn bits_prefix_of(&self, prefix: usize, other: &Self) -> bool

source§

impl BigEndianBitString for u64

source§

fn bits(&self) -> usize

source§

fn bits_inc(&mut self, prefix: usize) -> bool

source§

fn bit_get(&self, ndx: usize) -> bool

source§

fn bit_set(&mut self, ndx: usize, bit: bool)

source§

fn bit_flip(&mut self, ndx: usize)

source§

fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize

source§

fn set_false_from(&mut self, ndx: usize)

source§

fn is_false_from(&self, ndx: usize) -> bool

source§

fn set_true_from(&mut self, ndx: usize)

source§

fn is_true_from(&self, ndx: usize) -> bool

source§

fn bits_prefix_of(&self, prefix: usize, other: &Self) -> bool

source§

impl BigEndianBitString for u128

source§

fn bits(&self) -> usize

source§

fn bits_inc(&mut self, prefix: usize) -> bool

source§

fn bit_get(&self, ndx: usize) -> bool

source§

fn bit_set(&mut self, ndx: usize, bit: bool)

source§

fn bit_flip(&mut self, ndx: usize)

source§

fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize

source§

fn set_false_from(&mut self, ndx: usize)

source§

fn is_false_from(&self, ndx: usize) -> bool

source§

fn set_true_from(&mut self, ndx: usize)

source§

fn is_true_from(&self, ndx: usize) -> bool

source§

fn bits_prefix_of(&self, prefix: usize, other: &Self) -> bool

source§

impl BigEndianBitString for [u8]

source§

fn bits(&self) -> usize

source§

fn bits_inc(&mut self, prefix: usize) -> bool

source§

fn bit_get(&self, ndx: usize) -> bool

source§

fn bit_set(&mut self, ndx: usize, bit: bool)

source§

fn bit_flip(&mut self, ndx: usize)

source§

fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize

source§

fn set_false_from(&mut self, ndx: usize)

source§

fn is_false_from(&self, ndx: usize) -> bool

source§

fn set_true_from(&mut self, ndx: usize)

source§

fn is_true_from(&self, ndx: usize) -> bool

source§

fn bits_prefix_of(&self, prefix: usize, other: &Self) -> bool

source§

impl BigEndianBitString for [u16]

source§

fn bits(&self) -> usize

source§

fn bits_inc(&mut self, prefix: usize) -> bool

source§

fn bit_get(&self, ndx: usize) -> bool

source§

fn bit_set(&mut self, ndx: usize, bit: bool)

source§

fn bit_flip(&mut self, ndx: usize)

source§

fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize

source§

fn set_false_from(&mut self, ndx: usize)

source§

fn is_false_from(&self, ndx: usize) -> bool

source§

fn set_true_from(&mut self, ndx: usize)

source§

fn is_true_from(&self, ndx: usize) -> bool

source§

fn bits_prefix_of(&self, prefix: usize, other: &Self) -> bool

source§

impl BigEndianBitString for [u32]

source§

fn bits(&self) -> usize

source§

fn bits_inc(&mut self, prefix: usize) -> bool

source§

fn bit_get(&self, ndx: usize) -> bool

source§

fn bit_set(&mut self, ndx: usize, bit: bool)

source§

fn bit_flip(&mut self, ndx: usize)

source§

fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize

source§

fn set_false_from(&mut self, ndx: usize)

source§

fn is_false_from(&self, ndx: usize) -> bool

source§

fn set_true_from(&mut self, ndx: usize)

source§

fn is_true_from(&self, ndx: usize) -> bool

source§

fn bits_prefix_of(&self, prefix: usize, other: &Self) -> bool

source§

impl BigEndianBitString for [u64]

source§

fn bits(&self) -> usize

source§

fn bits_inc(&mut self, prefix: usize) -> bool

source§

fn bit_get(&self, ndx: usize) -> bool

source§

fn bit_set(&mut self, ndx: usize, bit: bool)

source§

fn bit_flip(&mut self, ndx: usize)

source§

fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize

source§

fn set_false_from(&mut self, ndx: usize)

source§

fn is_false_from(&self, ndx: usize) -> bool

source§

fn set_true_from(&mut self, ndx: usize)

source§

fn is_true_from(&self, ndx: usize) -> bool

source§

fn bits_prefix_of(&self, prefix: usize, other: &Self) -> bool

source§

impl BigEndianBitString for [u128]

source§

fn bits(&self) -> usize

source§

fn bits_inc(&mut self, prefix: usize) -> bool

source§

fn bit_get(&self, ndx: usize) -> bool

source§

fn bit_set(&mut self, ndx: usize, bit: bool)

source§

fn bit_flip(&mut self, ndx: usize)

source§

fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize

source§

fn set_false_from(&mut self, ndx: usize)

source§

fn is_false_from(&self, ndx: usize) -> bool

source§

fn set_true_from(&mut self, ndx: usize)

source§

fn is_true_from(&self, ndx: usize) -> bool

source§

fn bits_prefix_of(&self, prefix: usize, other: &Self) -> bool

Implementors§