pub trait FixedBitString {
const LEN: usize;
Show 13 methods
// Required methods
fn inc(&mut self, prefix: usize) -> bool;
fn get(&self, ndx: usize) -> bool;
fn set(&mut self, ndx: usize, bit: bool);
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 new_all_false() -> Self;
fn new_all_true() -> Self;
fn contains(&self, prefix: usize, other: &Self) -> bool;
// Provided methods
fn iter(&self, prefix: usize) -> Iter<Self> ⓘ
where Self: Sized + Clone { ... }
fn flip(&mut self, ndx: usize) { ... }
fn shared_prefix_len(&self, other: &Self) -> usize { ... }
}fixed only.Expand description
A bit string with fixed length.
All bits must me mutable, and there must be no dependencies between bits (i.e. setting one bit must not change any other bit).
Required Associated Constants§
Required Methods§
Sourcefn inc(&mut self, prefix: usize) -> bool
fn inc(&mut self, prefix: usize) -> bool
Treat bit string as integer, where bit 0 is the most significant bit.
Increment by one, i.e. start by incrementing the bit with the highest index.
Don’t touch first prefix bits; return true on overflow.
§Panics
Should panic if prefix > Self::LEN.
Sourcefn set_false_from(&mut self, ndx: usize)
fn set_false_from(&mut self, ndx: usize)
Set all bits in [ndx..] to false.
Doesn’t do anything if ndx >= Self::LEN.
Sourcefn is_false_from(&self, ndx: usize) -> bool
fn is_false_from(&self, ndx: usize) -> bool
Whether all bits in [ndx..] are false.
Returns true if ndx >= Self::LEN.
Sourcefn set_true_from(&mut self, ndx: usize)
fn set_true_from(&mut self, ndx: usize)
Set all bits in [ndx..] to true.
Doesn’t do anything if ndx >= Self::LEN.
Sourcefn is_true_from(&self, ndx: usize) -> bool
fn is_true_from(&self, ndx: usize) -> bool
Whether all bits in [ndx..] are true.
Returns true if ndx >= Self::LEN.
Sourcefn new_all_false() -> Self
fn new_all_false() -> Self
New bit string with all bits set to false.
Sourcefn new_all_true() -> Self
fn new_all_true() -> Self
New bit string with all bits set to true.
Provided Methods§
Sourcefn iter(&self, prefix: usize) -> Iter<Self> ⓘ
fn iter(&self, prefix: usize) -> Iter<Self> ⓘ
Iterate through all bit strings until inc overflows.
All generated values will share the first prefix bits. If you
want to iterate over all values make sure to call
self.set_false_from(prefix) before.
§Panics
Should panic if prefix > Self::LEN.
Length of the longest shared prefix of two bit strings.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl FixedBitString for Ipv4Addr
Available on crate feature net only.
impl FixedBitString for Ipv4Addr
net only.fixed only.Source§fn set_false_from(&mut self, ndx: usize)
fn set_false_from(&mut self, ndx: usize)
fixed only.Source§fn is_false_from(&self, ndx: usize) -> bool
fn is_false_from(&self, ndx: usize) -> bool
fixed only.Source§fn set_true_from(&mut self, ndx: usize)
fn set_true_from(&mut self, ndx: usize)
fixed only.Source§fn is_true_from(&self, ndx: usize) -> bool
fn is_true_from(&self, ndx: usize) -> bool
fixed only.Source§fn new_all_false() -> Self
fn new_all_false() -> Self
fixed only.Source§fn new_all_true() -> Self
fn new_all_true() -> Self
fixed only.Source§impl FixedBitString for Ipv6Addr
Available on crate feature net only.
impl FixedBitString for Ipv6Addr
net only.fixed only.Source§fn set_false_from(&mut self, ndx: usize)
fn set_false_from(&mut self, ndx: usize)
fixed only.Source§fn is_false_from(&self, ndx: usize) -> bool
fn is_false_from(&self, ndx: usize) -> bool
fixed only.Source§fn set_true_from(&mut self, ndx: usize)
fn set_true_from(&mut self, ndx: usize)
fixed only.Source§fn is_true_from(&self, ndx: usize) -> bool
fn is_true_from(&self, ndx: usize) -> bool
fixed only.Source§fn new_all_false() -> Self
fn new_all_false() -> Self
fixed only.Source§fn new_all_true() -> Self
fn new_all_true() -> Self
fixed only.