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§
sourcefn bits_inc(&mut self, prefix: usize) -> bool
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()
.
Length of the longest shared prefix of two bit strings.
sourcefn set_false_from(&mut self, ndx: usize)
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()
.
sourcefn is_false_from(&self, ndx: usize) -> bool
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()
.
sourcefn set_true_from(&mut self, ndx: usize)
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()
.
sourcefn is_true_from(&self, ndx: usize) -> bool
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()
.
sourcefn bits_prefix_of(&self, prefix_len: usize, value: &Self) -> bool
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.