Struct libp2p_kad::kbucket::KeyBytes
source · pub struct KeyBytes(/* private fields */);
Expand description
The raw bytes of a key in the DHT keyspace.
Implementations§
source§impl KeyBytes
impl KeyBytes
sourcepub fn new<T>(value: T) -> Self
pub fn new<T>(value: T) -> Self
Creates a new key in the DHT keyspace by running the given value through a random oracle.
sourcepub fn distance<U>(&self, other: &U) -> Distance
pub fn distance<U>(&self, other: &U) -> Distance
Computes the distance of the keys according to the XOR metric.
sourcepub fn for_distance(&self, d: Distance) -> KeyBytes
pub fn for_distance(&self, d: Distance) -> KeyBytes
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§
source§impl PartialEq for KeyBytes
impl PartialEq for KeyBytes
impl Eq for KeyBytes
impl StructuralPartialEq for KeyBytes
Auto Trait Implementations§
impl Freeze for KeyBytes
impl RefUnwindSafe for KeyBytes
impl Send for KeyBytes
impl Sync for KeyBytes
impl Unpin for KeyBytes
impl UnwindSafe for KeyBytes
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)