pub struct KBucketsTable<TKey, TVal> { /* private fields */ }
Expand description

A KBucketsTable represents a Kademlia routing table.

Implementations

Creates a new, empty Kademlia routing table with entries partitioned into buckets as per the Kademlia protocol.

The given pending_timeout specifies the duration after creation of a PendingEntry after which it becomes eligible for insertion into a full bucket, replacing the least-recently (dis)connected node.

Returns the local key.

Returns an Entry for the given key, representing the state of the entry in the routing table.

Returns an iterator over all buckets.

The buckets are ordered by proximity to the local_key, i.e. the first bucket is the closest bucket (containing at most one key).

Returns the bucket for the distance to the given key.

Returns None if the given key refers to the local key.

Consumes the next applied pending entry, if any.

When an entry is attempted to be inserted and the respective bucket is full, it may be recorded as pending insertion after a timeout, see InsertResult::Pending.

If the oldest currently disconnected entry in the respective bucket does not change its status until the timeout of pending entry expires, it is evicted and the pending entry inserted instead. These insertions of pending entries happens lazily, whenever the KBucketsTable is accessed, and the corresponding buckets are updated accordingly. The fact that a pending entry was applied is recorded in the KBucketsTable in the form of AppliedPending results, which must be consumed by calling this function.

Returns an iterator over the keys closest to target, ordered by increasing distance.

Returns an iterator over the nodes closest to the target key, ordered by increasing distance.

Counts the number of nodes between the local node and the node closest to target.

The number of nodes between the local node and the target are calculated by backtracking from the target towards the local key.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.