Struct libp2p_core::PeerId

source ·
pub struct PeerId { /* private fields */ }
Expand description

Identifier of a peer of the network.

The data is a multihash of the public key of the peer.

Implementations

Builds a PeerId from a public key.

Checks whether data is a valid PeerId. If so, returns the PeerId. If not, returns back the data as an error.

Turns a Multihash into a PeerId. If the multihash doesn’t use the correct algorithm, returns back the data as an error.

Generates a random peer ID from a cryptographically secure PRNG.

This is useful for randomly walking on a DHT, or for testing purposes.

Returns a raw bytes representation of this PeerId.

Note that this is not the same as the public key of the peer.

Returns a raw bytes representation of this PeerId.

Note that this is not the same as the public key of the peer.

Returns a base-58 encoded string of this PeerId.

Returns the raw bytes of the hash of this PeerId.

Checks whether the public key passed as parameter matches the public key of this PeerId.

Returns None if this PeerIds hash algorithm is not supported when encoding the given public key, otherwise Some boolean as the result of an equality check.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
Converts this type into the (usually inferred) input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.