[−][src]Struct libp2p::PeerId
Identifier of a peer of the network.
The data is a multihash of the public key of the peer.
Methods
impl PeerId
[src]
impl PeerId
pub fn from_public_key(public_key: PublicKey) -> PeerId
[src]
pub fn from_public_key(public_key: PublicKey) -> PeerId
Builds a PeerId
from a public key.
pub fn from_bytes(data: Vec<u8>) -> Result<PeerId, Vec<u8>>
[src]
pub fn from_bytes(data: Vec<u8>) -> Result<PeerId, Vec<u8>>
Checks whether data
is a valid PeerId
. If so, returns the PeerId
. If not, returns
back the data as an error.
pub fn from_multihash(data: Multihash) -> Result<PeerId, Multihash>
[src]
pub fn from_multihash(data: Multihash) -> Result<PeerId, Multihash>
Turns a Multihash
into a PeerId
. If the multihash doesn't use the correct algorithm,
returns back the data as an error.
pub fn random() -> PeerId
[src]
pub fn random() -> PeerId
Generates a random peer ID from a cryptographically secure PRNG.
This is useful for randomly walking on a DHT, or for testing purposes.
pub fn into_bytes(self) -> Vec<u8>
[src]
pub fn into_bytes(self) -> Vec<u8>
Returns a raw bytes representation of this PeerId
.
Note that this is not the same as the public key of the peer.
pub fn as_bytes(&self) -> &[u8]
[src]
pub fn as_bytes(&self) -> &[u8]
Returns a raw bytes representation of this PeerId
.
Note that this is not the same as the public key of the peer.
pub fn to_base58(&self) -> String
[src]
pub fn to_base58(&self) -> String
Returns a base-58 encoded string of this PeerId
.
pub fn digest(&self) -> &[u8]
[src]
pub fn digest(&self) -> &[u8]
Returns the raw bytes of the hash of this PeerId
.
pub fn is_public_key(&self, public_key: &PublicKey) -> Option<bool>
[src]
pub fn is_public_key(&self, public_key: &PublicKey) -> Option<bool>
Checks whether the public key passed as parameter matches the public key of this PeerId
.
Returns None
if this PeerId
s hash algorithm is not supported when encoding the
given public key, otherwise Some
boolean as the result of an equality check.
Trait Implementations
impl PartialEq<PeerId> for PeerId
[src]
impl PartialEq<PeerId> for PeerId
impl PartialEq<Multihash> for PeerId
[src]
impl PartialEq<Multihash> for PeerId
fn eq(&self, other: &Multihash) -> bool
[src]
fn eq(&self, other: &Multihash) -> bool
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Eq for PeerId
[src]
impl Eq for PeerId
impl Debug for PeerId
[src]
impl Debug for PeerId
impl Hash for PeerId
[src]
impl Hash for PeerId
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Into<Multihash> for PeerId
[src]
impl Into<Multihash> for PeerId
impl Clone for PeerId
[src]
impl Clone for PeerId
fn clone(&self) -> PeerId
[src]
fn clone(&self) -> PeerId
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl FromStr for PeerId
[src]
impl FromStr for PeerId
type Err = ParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<PeerId, <PeerId as FromStr>::Err>
[src]
fn from_str(s: &str) -> Result<PeerId, <PeerId as FromStr>::Err>
impl AsRef<Multihash> for PeerId
[src]
impl AsRef<Multihash> for PeerId
impl From<PublicKey> for PeerId
[src]
impl From<PublicKey> for PeerId
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T> Same for T
impl<T> Same for T
type Output = T
Should always be Self
impl<T> Erased for T
impl<T> Erased for T
impl<T> Erased for T
impl<T> Erased for T
impl<T> Typeable for T where
T: Any,
impl<T> Typeable for T where
T: Any,