pub type NodeId = Identifier<Ed25519>;
Expand description

Identifier of a peer node.

Aliased Type§

struct NodeId(PublicKey<Ed25519>);

Fields§

§0: PublicKey<Ed25519>

Implementations§

source§

impl<A: AsymmetricPublicKey> Identifier<A>

source

pub fn into_public_key(self) -> PublicKey<A>

source

pub fn to_bech32_str(&self) -> String

encode the Identifier into a bech32 string.

This is a human readable encoding that allows to check input validation. When displaying this identifier to the user it is preferable to provide the output of this function.

Serde implementation of Identifier provides the bech32 string support.

Example

let key : SigningKey<Ed25519> = SigningKey::generate(thread_rng());
let key = key.identifier();

println!("key: {}", key.to_bech32_str());
source

pub fn from_bech32_str(s: &str) -> Result<Self, Error>

try to decode the given bech32 string into a valid Identifier

source

pub fn to_hex(&self) -> String

encode the Identifier into an hexadecimal string

While this is still a human readable format. it is lesser than the output of Self::to_bech32_str as it does not provide user input verification.

Display implementation of Identifier provides the hexadecimal string support. as well as the FromStr implementation.

This format is, for example, used in the REST API.

Example

let key : SigningKey<Ed25519> = SigningKey::generate(thread_rng());
let key = key.identifier();

println!("key: {}", key.to_hex());
source

pub fn from_hex(s: &str) -> Result<Self, PublicKeyFromStrError>

try to decode the given hexadecimal string into a valid Identifier

source§

impl Identifier<Ed25519>

source

pub fn to_single_address(&self, discrimination: Discrimination) -> Address

construct a single address

source

pub fn to_group_address( &self, discrimination: Discrimination, group: PublicKey<Ed25519> ) -> Address

create a group address.

source

pub fn to_account_address(&self, discrimination: Discrimination) -> Address

create an account address.

Trait Implementations§

source§

impl<A: AsymmetricPublicKey> AsRef<PublicKey<A>> for Identifier<A>

source§

fn as_ref(&self) -> &PublicKey<A>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<A: AsymmetricPublicKey> Clone for Identifier<A>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<A: AsymmetricPublicKey> Debug for Identifier<A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, A: AsymmetricPublicKey> Deserialize<'de> for Identifier<A>

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<A: AsymmetricPublicKey> Display for Identifier<A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<A: AsymmetricPublicKey> From<PublicKey<A>> for Identifier<A>

source§

fn from(key: PublicKey<A>) -> Self

Converts to this type from the input type.
source§

impl<A: AsymmetricPublicKey> FromStr for Identifier<A>

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl<A: AsymmetricPublicKey> Hash for Identifier<A>

source§

fn hash<H>(&self, state: &mut H)where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<A: AsymmetricPublicKey> Ord for Identifier<A>

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<A: AsymmetricPublicKey> PartialEq<Identifier<A>> for Identifier<A>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: AsymmetricPublicKey> PartialOrd<Identifier<A>> for Identifier<A>

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<A: AsymmetricPublicKey> Serialize for Identifier<A>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<A: AsymmetricPublicKey> Eq for Identifier<A>