pub struct KeyBytes(_);
Expand description
The raw bytes of a key in the DHT keyspace.
Implementations
sourceimpl KeyBytes
impl KeyBytes
sourcepub fn new<T>(value: T) -> KeyBytes where
T: Borrow<[u8]>,
pub fn new<T>(value: T) -> KeyBytes where
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) -> Distance where
U: AsRef<KeyBytes>,
pub fn distance<U>(&self, other: &U) -> Distance where
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
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more