Skip to main content

Identity

Trait Identity 

Source
pub trait Identity: Send + Sync {
    // Required methods
    fn capabilities(&self) -> Vec<(IdentityKind, JwsAlgorithm)>;
    fn identifier<'life0, 'life1, 'async_trait>(
        &'life0 self,
        kind: &'life1 IdentityKind,
        alg: JwsAlgorithm,
    ) -> Pin<Box<dyn Future<Output = Result<Identifier, IdentityError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn public_jwk<'life0, 'life1, 'async_trait>(
        &'life0 self,
        kind: &'life1 IdentityKind,
        alg: JwsAlgorithm,
    ) -> Pin<Box<dyn Future<Output = Result<Jwk, IdentityError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn signer<'life0, 'life1, 'async_trait>(
        &'life0 self,
        kind: &'life1 IdentityKind,
        alg: JwsAlgorithm,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Signer + '_>, IdentityError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A party that signs: the identifiers it controls and the keys behind them.

See the module documentation for how a protocol uses it. Every method answers for a (kind, alg) pair; for one pair, identifier, public_jwk and signer name the same key.

Required Methods§

Source

fn capabilities(&self) -> Vec<(IdentityKind, JwsAlgorithm)>

The (kind, alg) pairs this identity can sign for, for negotiation.

Source

fn identifier<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Identifier, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The identifier for (kind, alg). A thumbprint, a did:key or a did:jwk is derived from the key bound to the pair, so it names the same key as public_jwk and signer only for the same pair.

§Errors

IdentityError::UnsupportedKind or IdentityError::UnsupportedAlgorithm when the identity cannot answer for the pair, and whatever producing the identifier reports.

Source

fn public_jwk<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Jwk, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The public key that signer(kind, alg) signs with, for cnf.jwk, sub_jwk or a jwk header.

§Errors

As identifier.

Source

fn signer<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Signer + '_>, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

A signer for (kind, alg). For IdentityKind::Did, Signer::kid is the absolute DID URL of the verification method; for IdentityKind::JwkThumbprint it is None and the caller puts public_jwk in the header.

§Errors

As identifier.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Identity + ?Sized> Identity for &T

Source§

fn capabilities(&self) -> Vec<(IdentityKind, JwsAlgorithm)>

Source§

fn identifier<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Identifier, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn public_jwk<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Jwk, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn signer<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Signer + '_>, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl<T: Identity + ?Sized> Identity for Arc<T>

Source§

fn capabilities(&self) -> Vec<(IdentityKind, JwsAlgorithm)>

Source§

fn identifier<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Identifier, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn public_jwk<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Jwk, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn signer<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Signer + '_>, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl<T: Identity + ?Sized> Identity for Box<T>

Source§

fn capabilities(&self) -> Vec<(IdentityKind, JwsAlgorithm)>

Source§

fn identifier<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Identifier, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn public_jwk<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Jwk, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn signer<'life0, 'life1, 'async_trait>( &'life0 self, kind: &'life1 IdentityKind, alg: JwsAlgorithm, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Signer + '_>, IdentityError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§