pub struct Bloom {
pub mandatory: u128,
pub optional: u128,
}Expand description
Two 128-bit bloom filters (k=2 hashes) bundled into one wire type.
mandatory holds items the local node REQUIRES peers to also support.
optional holds items the local node would LIKE peers to support
but doesn’t require.
Content-agnostic: items can be protocol ids, swarm keys, or any other identifier hashable as bytes. Discovery-layer hint, not
Fields§
§mandatory: u128§optional: u128Implementations§
Source§impl Bloom
impl Bloom
Sourcepub fn add_mandatory<I: AsRef<[u8]>>(&mut self, item: I)
pub fn add_mandatory<I: AsRef<[u8]>>(&mut self, item: I)
Insert a mandatory item.
Sourcepub fn add_optional<I: AsRef<[u8]>>(&mut self, item: I)
pub fn add_optional<I: AsRef<[u8]>>(&mut self, item: I)
Insert an optional item.
Sourcepub fn may_contain<I: AsRef<[u8]>>(&self, item: I) -> bool
pub fn may_contain<I: AsRef<[u8]>>(&self, item: I) -> bool
True if this filter might contain item in either set.
Sourcepub fn covers_mandatory(&self, mine: &Self) -> bool
pub fn covers_mandatory(&self, mine: &Self) -> bool
True if this peer’s full set of items covers every bit in
mine.mandatory.
Sourcepub fn intersects_optional(&self, mine: &Self) -> bool
pub fn intersects_optional(&self, mine: &Self) -> bool
True if this peer’s full set of items shares at least one bit
with mine.optional. Trivially false if mine.optional is empty.
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for Bloom
impl<'__de, __Context> BorrowDecode<'__de, __Context> for Bloom
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
impl Copy for Bloom
impl Eq for Bloom
impl StructuralPartialEq for Bloom
Auto Trait Implementations§
impl Freeze for Bloom
impl RefUnwindSafe for Bloom
impl Send for Bloom
impl Sync for Bloom
impl Unpin for Bloom
impl UnsafeUnpin for Bloom
impl UnwindSafe for Bloom
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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