pub struct PeerId(/* private fields */);Expand description
Peer ID derived from public key (256-bit).
The canonical peer identity in the Saorsa network. Computed as the BLAKE3 hash of the node’s ML-DSA-65 public key.
Serializes as a hex string (64 characters) in all formats to maintain
wire compatibility with the existing postcard-based WireMessage protocol.
Implementations§
Source§impl PeerId
impl PeerId
Sourcepub fn xor_distance(&self, other: &PeerId) -> [u8; 32]
pub fn xor_distance(&self, other: &PeerId) -> [u8; 32]
XOR distance to another peer ID (for Kademlia).
Sourcepub fn distance(&self, other: &PeerId) -> [u8; 32]
pub fn distance(&self, other: &PeerId) -> [u8; 32]
XOR distance alias — provided so code using DhtKey can call
.distance() unchanged.
Sourcepub fn from_hex(hex_str: &str) -> Result<PeerId, PeerIdParseError>
pub fn from_hex(hex_str: &str) -> Result<PeerId, PeerIdParseError>
Create from a hex-encoded string (64 hex characters -> 32 bytes).
Sourcepub fn short_hex(&self) -> String
pub fn short_hex(&self) -> String
Return a short hex representation (first 8 bytes = 16 hex characters).
Useful for compact log output.
Sourcepub fn from_bytes(bytes: [u8; 32]) -> PeerId
pub fn from_bytes(bytes: [u8; 32]) -> PeerId
Construct from raw bytes.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PeerId
impl<'de> Deserialize<'de> for PeerId
Source§fn deserialize<D>(
deserializer: D,
) -> Result<PeerId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<PeerId, <D as Deserializer<'de>>::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
Source§impl Serialize for PeerId
impl Serialize for PeerId
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.