Skip to main content

Resolver

Struct Resolver 

Source
pub struct Resolver { /* private fields */ }
Expand description

Routes each DID to the DidResolver registered for its method, with an optional DocumentCache in front.

Built with Resolver::builder. The resolver is Send + Sync and meant to be shared, in an Arc or by reference, by every task of an application. See the module documentation for the resolution and dereferencing semantics and an example.

Implementations§

Source§

impl Resolver

Source

pub async fn dereference( &self, url: &DidUrl, ) -> Result<Dereferenced, DereferenceError>

Dereferences url: the DID document when the URL is a bare DID, else the verification method or service whose id is the URL. The fragment is looked up against the id of the resolved document, which is the canonical DID when url names an equivalent one.

The versionId and versionTime DID parameters select the version of the document and are passed to the method’s resolver as resolution options. A path, any other query parameter and the service/relativeRef parameters are method-specific and not dereferenced here.

§Errors
Source

pub async fn resolve_verification_method( &self, url: &DidUrl, relationship: Option<VerificationRelationship>, ) -> Result<VerificationMethod, DereferenceError>

The verification method url names, which must be usable for relationship when one is given (the verificationRelationship dereferencing option of DID Resolution).

§Errors

As dereference, plus DereferenceError::NotVerificationMethod when the URL has no fragment or names a service, and DereferenceError::NotInRelationship when the method is not referenced or embedded under relationship.

Source

pub async fn resolve_public_key( &self, url: &DidUrl, relationship: Option<VerificationRelationship>, ) -> Result<Jwk, DereferenceError>

The public key of the verification method url names, as a JWK: its publicKeyJwk, or its publicKeyMultibase decoded as a Multikey. The method must be usable for relationship when one is given: assertionMethod for the key that signed a credential, authentication for the key that signed a presentation.

§Errors

As resolve_verification_method, plus DereferenceError::NoJwk when the method carries publicKeyMultibase material that is not a Multikey this crate can decode.

Source§

impl Resolver

Source

pub fn builder() -> ResolverBuilder

A builder with no method registered and no cache.

Source

pub fn methods(&self) -> Vec<&str>

The registered method names, sorted.

Source

pub fn supports(&self, method: &str) -> bool

Whether a resolver for method (web, not did:web) is registered.

Source

pub fn resolver(&self, method: &str) -> Option<&Arc<dyn DidResolver>>

The resolver registered for method, if any.

Source

pub fn cache(&self) -> Option<&DocumentCache>

The cache, when the resolver was built with one.

Source

pub async fn resolve( &self, did: &Did, ) -> Result<ResolutionResult, ResolutionError>

Resolves did without options, through the cache when there is one.

On success the result holds the document, or no document and deactivated: true in its document metadata when the DID has been deactivated.

§Errors

ResolutionErrorKind::MethodNotSupported when no resolver is registered for the method of did; otherwise what the method’s resolver reports, as Err or in its resolution metadata; ResolutionErrorKind::NotFound when it reports neither a document nor an error nor deactivation; ResolutionErrorKind::InvalidDidDocument when the document’s id is neither did nor the canonicalId of the document metadata.

Source

pub async fn resolve_with( &self, did: &Did, options: &ResolutionOptions, ) -> Result<ResolutionResult, ResolutionError>

Resolves did with options, bypassing the cache unless options is empty.

§Errors

As resolve.

Source

pub async fn resolve_document( &self, did: &Did, ) -> Result<DidDocument, ResolutionError>

The DID document of did.

§Errors

As resolve; a deactivated DID is ResolutionErrorKind::NotFound, even when the method still returns its last document.

Trait Implementations§

Source§

impl Debug for Resolver

Source§

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

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

impl KeyResolver for Resolver

Resolves a KeyReference::DidUrl by dereferencing it to a verification method listed under the relationship of the role; every other reference is Unsupported.

Source§

fn resolve_key<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 KeyReference, role: KeyRole, ) -> Pin<Box<dyn Future<Output = Result<Jwk, KeyResolutionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The public key key names, usable in role. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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.

Source§

impl<T> Instrument for T

Source§

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

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

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 T
where 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.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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