Struct libp2p::kad::kbucket::KeyBytes [−][src]
pub struct KeyBytes(_);
The raw bytes of a key in the DHT keyspace.
Implementations
impl KeyBytes[src]
impl KeyBytes[src]pub fn new<T>(value: T) -> KeyBytes where
T: Borrow<[u8]>, [src]
T: Borrow<[u8]>,
Creates a new key in the DHT keyspace by running the given value through a random oracle.
pub fn distance<U>(&self, other: &U) -> Distance where
U: AsRef<KeyBytes>, [src]
U: AsRef<KeyBytes>,
Computes the distance of the keys according to the XOR metric.
pub fn for_distance(&self, d: Distance) -> KeyBytes[src]
Returns the uniquely determined key with the given distance to self.
This implements the following equivalence:
self xor other = distance <==> other = self xor distance