Ibf

Struct Ibf 

Source
pub struct Ibf { /* private fields */ }
Expand description

A fixed-width Invertible Bloom Filter over u64 hash values.

k hash functions are simulated by rotating a seed before each cell selection. For PSync, set elements are hashes of NDN name strings.

Implementations§

Source§

impl Ibf

Source

pub fn new(size: usize, k: usize) -> Self

Create an IBF with size cells and k hash functions.

Source

pub fn from_cells(cells: Vec<(u64, u64, i64)>) -> Self

Create an IBF from raw cell data (xor_sum, hash_sum, count).

Uses k = 3 hash functions (the PSync default). The number of cells is inferred from the length of cells.

Source

pub fn cells(&self) -> Vec<(u64, u64, i64)>

Export cells as (xor_sum, hash_sum, count) tuples for wire encoding.

Source

pub fn insert(&mut self, value: u64)

Insert a hash value into the IBF.

Source

pub fn remove(&mut self, value: u64)

Remove a hash value from the IBF.

Source

pub fn subtract(&self, other: &Ibf) -> Ibf

Subtract other from self (XOR fields, subtract counts).

The result encodes the symmetric difference of the two sets.

Source

pub fn decode(&self) -> Option<(HashSet<u64>, HashSet<u64>)>

Attempt to decode the symmetric difference from a subtracted IBF.

Returns Some((in_self_not_other, in_other_not_self)) on success, or None if the difference is too large for the IBF to decode.

Trait Implementations§

Source§

impl Clone for Ibf

Source§

fn clone(&self) -> Ibf

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Ibf

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Ibf

§

impl RefUnwindSafe for Ibf

§

impl Send for Ibf

§

impl Sync for Ibf

§

impl Unpin for Ibf

§

impl UnwindSafe for Ibf

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.