pub struct PeerId { /* private fields */ }Expand description
Who a peer is: the hash of its public key or certificate, the whole of what one peer is told of another.
The canonical text form, and the Display form, is <alg>:<hash>: the
algorithm name, a colon and lowercase hexadecimal, sha256:3f15.... For an X.509
certificate openssl x509 -outform DER | sha256sum reproduces the hex. FromStr also
accepts:
- bare hexadecimal of a supported digest’s length (64 characters is SHA-256);
- hexadecimal pairs separated by colons (
AA:BB:...), as most tools print it; - for SHA-256 only, 52 base32 characters, grouped in fours by
-or not (to_base32_grouped), meant to be read aloud.
Text that is the length of an MD5 digest, or names md5, is Error::WeakDigest.
Equality is constant time.
Implementations§
Source§impl PeerId
impl PeerId
Sourcepub fn from_bytes(bytes: [u8; 32]) -> Self
pub fn from_bytes(bytes: [u8; 32]) -> Self
A SHA-256 id from its 32 digest bytes.
Sourcepub fn to_base32_grouped(&self) -> String
pub fn to_base32_grouped(&self) -> String
SHA-256 only: 52 uppercase base32 characters in 13 groups of four separated by -,
for screens that show it and for reading aloud. Any other digest gives its
canonical form.
Trait Implementations§
impl Copy for PeerId
Source§impl<'de> Deserialize<'de> for PeerId
Available on crate feature serde only.
impl<'de> Deserialize<'de> for PeerId
Available on crate feature
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for PeerId
Source§impl Ord for PeerId
impl Ord for PeerId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
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