pub struct Identifier<A: AsymmetricPublicKey>(PublicKey<A>);
Expand description

a cryptographic identifier. Can be used to identify a signature has been generated by its associated SigningKey.

More info at the module documentation

Tuple Fields§

§0: PublicKey<A>

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 From<Identifier<Ed25519>> for ConsensusLeaderId

source§

fn from(identifier: Identifier<Ed25519>) -> Self

Converts to this type from the input type.
source§

impl From<Identifier<Ed25519>> for Identifier

source§

fn from(identifier: Identifier<AccountAlg>) -> Self

Converts to this type from the input type.
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>

Auto Trait Implementations§

§

impl<A> RefUnwindSafe for Identifier<A>where <A as AsymmetricPublicKey>::Public: RefUnwindSafe,

§

impl<A> Send for Identifier<A>where <A as AsymmetricPublicKey>::Public: Send,

§

impl<A> Sync for Identifier<A>where <A as AsymmetricPublicKey>::Public: Sync,

§

impl<A> Unpin for Identifier<A>where <A as AsymmetricPublicKey>::Public: Unpin,

§

impl<A> UnwindSafe for Identifier<A>where <A as AsymmetricPublicKey>::Public: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,