Trait xstack_kad::kbucket::KBucketKey

source ·
pub trait KBucketKey {
    type Length: ArrayLength;
    type Distance: KBucketDistance;

    // Required methods
    fn distance(&self, rhs: &Self) -> Self::Distance
       where Self: Sized;
    fn longest_common_prefix(&self, rhs: &Self) -> usize
       where Self: Sized;
    fn for_distance(&self, distance: Self::Distance) -> Self;
}
Expand description

A key type trait used for KBucketTable

Required Associated Types§

Required Methods§

source

fn distance(&self, rhs: &Self) -> Self::Distance
where Self: Sized,

Calculate the distance between two keys.

source

fn longest_common_prefix(&self, rhs: &Self) -> usize
where Self: Sized,

Returns the uniquely determined key with the given distance to self.

This implements the following equivalence:

self xor other = distance <==> other = self xor distance

source

fn for_distance(&self, distance: Self::Distance) -> Self

Returns the longest common prefix length with rhs.

Object Safety§

This trait is not object safe.

Implementors§