[][src]Trait libp2p_kad::kbucket::KBucketsPeerId

pub trait KBucketsPeerId<TOther = Self>: PartialEq<TOther> {
    fn distance_with(&self, other: &TOther) -> u32;
fn max_distance() -> NonZeroUsize; }

Trait that must be implemented on types that can be used as an identifier in a k-bucket.

If TOther is not the same as Self, it represents an entry already in the k-buckets that Self can compare against.

Required methods

fn distance_with(&self, other: &TOther) -> u32

Computes the XOR of this value and another one. The lower the closer.

fn max_distance() -> NonZeroUsize

Returns then number of bits that are necessary to store the distance between peer IDs. Used for pre-allocations.

Loading content...

Implementations on Foreign Types

impl KBucketsPeerId<PeerId> for PeerId[src]

impl KBucketsPeerId<PeerId> for Multihash[src]

impl KBucketsPeerId<Multihash> for Multihash[src]

impl<A, B> KBucketsPeerId<(A, B)> for (A, B) where
    A: KBucketsPeerId + PartialEq,
    B: KBucketsPeerId + PartialEq
[src]

impl<'a, T> KBucketsPeerId<&'a T> for &'a T where
    T: KBucketsPeerId
[src]

Loading content...

Implementors

Loading content...