Struct bitar::chunker::FilterBits
source · pub struct FilterBits(pub u32);
Expand description
Helper type for creating a bit mask to use while scanning for chunk boundaries.
The bit mask given from the filter is used to match against the rolling hash sum.
When sum | filter_mask == sum
then we have found a chunk boundary.
That is, with a mask set to 0b1 a chunk will be found every 2nd byte on average.
With a mask set to 0b11 a chunk will be found every 4th byte on average.
Tuple Fields§
§0: u32
Implementations§
source§impl FilterBits
impl FilterBits
sourcepub fn from_size(size: u32) -> Self
pub fn from_size(size: u32) -> Self
Create new filter mask with an average target size of the given value.
The actual target size will be the given size rounded down to the closest power of 2 value.
sourcepub fn from_bits(bits: u32) -> Self
pub fn from_bits(bits: u32) -> Self
Create new filter mask from a number of bits.
Eg 1 => 0b1, 2 => 0b11, 3 => 0b111 etc.
sourcepub fn chunk_target_average(self) -> u32
pub fn chunk_target_average(self) -> u32
Get the average target size from the filter.
Trait Implementations§
source§impl Clone for FilterBits
impl Clone for FilterBits
source§fn clone(&self) -> FilterBits
fn clone(&self) -> FilterBits
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for FilterBits
impl Debug for FilterBits
source§impl Hash for FilterBits
impl Hash for FilterBits
source§impl PartialEq for FilterBits
impl PartialEq for FilterBits
source§fn eq(&self, other: &FilterBits) -> bool
fn eq(&self, other: &FilterBits) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for FilterBits
impl Eq for FilterBits
impl StructuralPartialEq for FilterBits
Auto Trait Implementations§
impl Freeze for FilterBits
impl RefUnwindSafe for FilterBits
impl Send for FilterBits
impl Sync for FilterBits
impl Unpin for FilterBits
impl UnwindSafe for FilterBits
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more