[][src]Struct libp2p_kad::kbucket::KBucketsTable

pub struct KBucketsTable<TPeerId, TVal> { /* fields omitted */ }

Table of k-buckets.

Methods

impl<TPeerId, TVal> KBucketsTable<TPeerId, TVal> where
    TPeerId: KBucketsPeerId
[src]

pub fn new(my_id: TPeerId, unresponsive_timeout: Duration) -> Self[src]

Builds a new routing table.

Important traits for BucketsIter<'a, TPeerId, TVal>
pub fn buckets(&mut self) -> BucketsIter<TPeerId, TVal>[src]

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.

pub fn my_id(&self) -> &TPeerId[src]

Returns the ID of the local node.

pub fn get(&self, id: &TPeerId) -> Option<&TVal>[src]

Returns the value associated to a node, if any is present.

Does not include pending nodes.

pub fn get_mut(&mut self, id: &TPeerId) -> Option<&mut TVal>[src]

Returns the value associated to a node, if any is present.

Does not include pending nodes.

pub fn entry_mut(&mut self, id: &TPeerId) -> Option<&mut TVal> where
    TVal: Default
[src]

Returns the value associated to a node if any is present. Otherwise, tries to add the node to the table in a disconnected state and return its value. Returns None if id is the local peer, or if the table is full.

pub fn set_connected(&mut self, id: &TPeerId) -> Update<TPeerId> where
    TVal: Default
[src]

Reports that we are connected to the given node.

This inserts the node in the k-buckets, if possible. If it is already in a k-bucket, puts it above the disconnected nodes. If it is not already in a k-bucket, then the value will be built with the Default trait.

pub fn set_disconnected(&mut self, id: &TPeerId)[src]

Reports that we are now disconnected from the given node.

This does not remove the node from the k-buckets, but moves it underneath the nodes we are still connected to.

pub fn find_closest<TOther>(&mut self, id: &TOther) -> VecIntoIter<TPeerId> where
    TPeerId: Clone + KBucketsPeerId<TOther>, 
[src]

Finds the num nodes closest to id, ordered by distance.

pub fn find_closest_with_self<TOther>(
    &mut self,
    id: &TOther
) -> VecIntoIter<TPeerId> where
    TPeerId: Clone + KBucketsPeerId<TOther>, 
[src]

Same as find_closest, but includes the local peer as well.

Trait Implementations

impl<TPeerId: Clone, TVal: Clone> Clone for KBucketsTable<TPeerId, TVal>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<TPeerId: Debug, TVal: Debug> Debug for KBucketsTable<TPeerId, TVal>[src]

Auto Trait Implementations

impl<TPeerId, TVal> Send for KBucketsTable<TPeerId, TVal> where
    TPeerId: Send,
    TVal: Send

impl<TPeerId, TVal> Sync for KBucketsTable<TPeerId, TVal> where
    TPeerId: Sync,
    TVal: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same for T

type Output = T

Should always be Self

impl<T> Erased for T