Struct libp2p_kad::kbucket::KBucketsTable
source · pub struct KBucketsTable<Id, Val> { /* private fields */ }
Expand description
Table of k-buckets.
Implementations
sourceimpl<Id, Val> KBucketsTable<Id, Val>where
Id: KBucketsPeerId,
impl<Id, Val> KBucketsTable<Id, Val>where
Id: KBucketsPeerId,
sourcepub fn buckets(&mut self) -> BucketsIter<'_, Id, Val>ⓘNotable traits for BucketsIter<'a, Id, Val>impl<'a, Id: 'a, Val: 'a> Iterator for BucketsIter<'a, Id, Val> type Item = Bucket<'a, Id, Val>;
pub fn buckets(&mut self) -> BucketsIter<'_, Id, Val>ⓘNotable traits for BucketsIter<'a, Id, Val>impl<'a, Id: 'a, Val: 'a> Iterator for BucketsIter<'a, Id, Val> type Item = Bucket<'a, Id, Val>;
Returns an iterator to all the buckets of this table.
Ordered by proximity to the local node. Closest bucket (with max. one node in it) comes first.
sourcepub fn find_closest(&mut self, id: &Id) -> VecIntoIter<Id>where
Id: Clone,
pub fn find_closest(&mut self, id: &Id) -> VecIntoIter<Id>where
Id: Clone,
Finds the num
nodes closest to id
, ordered by distance.
sourcepub fn find_closest_with_self(&mut self, id: &Id) -> VecIntoIter<Id>where
Id: Clone,
pub fn find_closest_with_self(&mut self, id: &Id) -> VecIntoIter<Id>where
Id: Clone,
Same as find_closest
, but includes the local peer as well.
sourcepub fn update(&mut self, id: Id, value: Val) -> UpdateOutcome<Id, Val>
pub fn update(&mut self, id: Id, value: Val) -> UpdateOutcome<Id, Val>
Marks the node as “most recent” in its bucket and modifies the value associated to it. This function should be called whenever we receive a communication from a node.
Trait Implementations
sourceimpl<Id: Clone, Val: Clone> Clone for KBucketsTable<Id, Val>
impl<Id: Clone, Val: Clone> Clone for KBucketsTable<Id, Val>
sourcefn clone(&self) -> KBucketsTable<Id, Val>
fn clone(&self) -> KBucketsTable<Id, Val>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations
impl<Id, Val> RefUnwindSafe for KBucketsTable<Id, Val>where
Id: RefUnwindSafe,
Val: RefUnwindSafe,
impl<Id, Val> Send for KBucketsTable<Id, Val>where
Id: Send,
Val: Send,
impl<Id, Val> Sync for KBucketsTable<Id, Val>where
Id: Sync,
Val: Sync,
impl<Id, Val> Unpin for KBucketsTable<Id, Val>where
Id: Unpin,
Val: Unpin,
impl<Id, Val> UnwindSafe for KBucketsTable<Id, Val>where
Id: UnwindSafe,
Val: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more