Struct libp2p::kad::kbucket::KeyBytes[][src]

pub struct KeyBytes(_);

The raw bytes of a key in the DHT keyspace.

Implementations

impl KeyBytes[src]

pub fn new<T>(value: T) -> KeyBytes where
    T: Borrow<[u8]>, 
[src]

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]

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

Trait Implementations

impl AsRef<KeyBytes> for KeyBytes[src]

impl<T> AsRef<KeyBytes> for Key<T>[src]

impl<TKey, TVal> AsRef<KeyBytes> for EntryView<TKey, TVal> where
    TKey: AsRef<KeyBytes>, 
[src]

impl Clone for KeyBytes[src]

impl Debug for KeyBytes[src]

impl Eq for KeyBytes[src]

impl<T> Into<KeyBytes> for Key<T>[src]

impl PartialEq<KeyBytes> for KeyBytes[src]

impl StructuralEq for KeyBytes[src]

impl StructuralPartialEq for KeyBytes[src]

Auto Trait Implementations

impl RefUnwindSafe for KeyBytes

impl Send for KeyBytes

impl Sync for KeyBytes

impl Unpin for KeyBytes

impl UnwindSafe for KeyBytes

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]