pub struct KeyBytes(_);
Expand description
The raw bytes of a key in the DHT keyspace.
Implementations§
source§impl KeyBytes
impl KeyBytes
sourcepub fn new<T>(value: T) -> KeyByteswhere
T: Borrow<[u8]>,
pub fn new<T>(value: T) -> KeyByteswhere T: Borrow<[u8]>,
Creates a new key in the DHT keyspace by running the given value through a random oracle.
sourcepub fn distance<U>(&self, other: &U) -> Distancewhere
U: AsRef<KeyBytes>,
pub fn distance<U>(&self, other: &U) -> Distancewhere U: AsRef<KeyBytes>,
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<KeyBytes> for KeyBytes
impl PartialEq<KeyBytes> for KeyBytes
impl Eq for KeyBytes
impl StructuralEq for KeyBytes
impl StructuralPartialEq for KeyBytes
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§
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