Struct libp2p_identity::PeerId
source · pub struct PeerId { /* private fields */ }
Expand description
Identifier of a peer of the network.
The data is a CIDv0 compatible multihash of the protobuf encoded public key of the peer as specified in specs/peer-ids.
Implementations§
source§impl PeerId
impl PeerId
sourcepub fn from_public_key(key: &PublicKey) -> PeerId
pub fn from_public_key(key: &PublicKey) -> PeerId
Builds a PeerId
from a public key.
sourcepub fn from_bytes(data: &[u8]) -> Result<PeerId, ParseError>
pub fn from_bytes(data: &[u8]) -> Result<PeerId, ParseError>
Parses a PeerId
from bytes.
sourcepub fn from_multihash(multihash: Multihash<64>) -> Result<PeerId, Multihash<64>>
pub fn from_multihash(multihash: Multihash<64>) -> Result<PeerId, Multihash<64>>
Tries to turn a Multihash
into a PeerId
.
If the multihash does not use a valid hashing algorithm for peer IDs,
or the hash value does not satisfy the constraints for a hashed
peer ID, it is returned as an Err
.
Trait Implementations§
source§impl Ord for PeerId
impl Ord for PeerId
source§impl PartialEq for PeerId
impl PartialEq for PeerId
source§impl PartialOrd for PeerId
impl PartialOrd for PeerId
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for PeerId
impl Eq for PeerId
impl StructuralEq for PeerId
impl StructuralPartialEq for PeerId
Auto Trait Implementations§
impl RefUnwindSafe for PeerId
impl Send for PeerId
impl Sync for PeerId
impl Unpin 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