[]Struct ckb_network::PeerId

pub struct PeerId { /* fields omitted */ }

Identifier of a peer of the network

The data is a hash of the public key of the peer

Implementations

impl PeerId

pub fn from_public_key(public_key: &PublicKey) -> PeerId

Builds a PeerId from a public key.

pub fn from_bytes(data: Vec<u8, Global>) -> Result<PeerId, ()>

If data is a valid PeerId, return PeerId, else return error

pub fn random() -> PeerId

Return a random PeerId

pub fn as_bytes(&self) -> &[u8]

Return raw bytes representation of this peer id

pub fn into_bytes(self) -> Vec<u8, Global>

Consume self, return raw bytes representation of this peer id

pub fn to_base58(&self) -> String

Returns a base-58 encoded string of this PeerId.

pub fn digest(&self) -> &[u8]

Returns the raw bytes of the hash of this PeerId.

pub fn is_public_key(&self, public_key: &PublicKey) -> bool

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

Trait Implementations

impl Clone for PeerId

impl Debug for PeerId

impl Eq for PeerId

impl From<PublicKey> for PeerId

impl FromStr for PeerId

type Err = ()

The associated error which can be returned from parsing.

impl Hash for PeerId

impl PartialEq<PeerId> for PeerId

impl PartialOrd<PeerId> for PeerId

impl StructuralEq for PeerId

impl StructuralPartialEq for PeerId

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AsAny for T where
    T: Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,