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

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

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

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() -> usize

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

Note: Returning 0 would lead to a panic.

Loading content...

Implementations on Foreign Types

impl KBucketsPeerId<PeerId> for PeerId[src]

impl KBucketsPeerId<Multihash> for PeerId[src]

impl KBucketsPeerId<Multihash> for Multihash[src]

Loading content...

Implementors

Loading content...