pub struct PeerId(/* private fields */);Expand description
Unique identifier for a peer in the network
Implementations§
Source§impl PeerId
impl PeerId
Sourcepub fn from_bytes(bytes: [u8; 32]) -> Self
pub fn from_bytes(bytes: [u8; 32]) -> Self
Create PeerId from bytes
Sourcepub fn xor_distance(&self, other: &PeerId) -> [u8; 32]
pub fn xor_distance(&self, other: &PeerId) -> [u8; 32]
Calculate XOR distance to another PeerId (for Kademlia)
Sourcepub fn leading_zeros_to(&self, other: &PeerId) -> usize
pub fn leading_zeros_to(&self, other: &PeerId) -> usize
Count leading zeros in the XOR distance (for Kademlia bucket calculation)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PeerId
impl<'de> Deserialize<'de> for PeerId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for PeerId
impl Ord for PeerId
Source§impl PartialOrd for PeerId
impl PartialOrd for PeerId
impl Copy for PeerId
impl Eq for PeerId
impl StructuralPartialEq for PeerId
Auto Trait Implementations§
impl Freeze for PeerId
impl RefUnwindSafe for PeerId
impl Send for PeerId
impl Sync for PeerId
impl Unpin for PeerId
impl UnsafeUnpin for PeerId
impl UnwindSafe for PeerId
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