pub trait DIDResolver: Sync {
    // Required method
    fn resolve<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        did: &'life1 str,
        input_metadata: &'life2 ResolutionInputMetadata
    ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn resolve_representation<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        did: &'life1 str,
        input_metadata: &'life2 ResolutionInputMetadata
    ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Vec<u8>, Option<DocumentMetadata>)> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn dereference<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _primary_did_url: &'life1 PrimaryDIDURL,
        _did_url_dereferencing_input_metadata: &'life2 DereferencingInputMetadata
    ) -> Pin<Box<dyn Future<Output = Option<(DereferencingMetadata, Content, ContentMetadata)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn to_did_method(&self) -> Option<&dyn DIDMethod> { ... }
}
Expand description

A DID resolver, implementing the DID Resolution algorithm and optionally DID URL Dereferencing.

Example

An example of a DID resolver with a static DID document.

use async_trait::async_trait;
use ssi_dids::Document;
use ssi_dids::did_resolve::{
    DIDResolver, DocumentMetadata, ResolutionInputMetadata, ResolutionMetadata,
    ERROR_NOT_FOUND
};

pub struct DIDExampleStatic;

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl DIDResolver for DIDExampleStatic {
    async fn resolve(
        &self,
        did: &str,
        _input_metadata: &ResolutionInputMetadata,
    ) -> (
        ResolutionMetadata,
        Option<Document>,
        Option<DocumentMetadata>,
    ) {
        match did {
            "did:example:foo" => {
                let doc = match Document::from_json(include_str!("../../tests/did-example-foo.json")) {
                    Ok(doc) => doc,
                    Err(e) => {
                        return (
                            ResolutionMetadata::from_error(&format!(
                                "Unable to parse DID document: {:?}",
                                e
                            )),
                            None,
                            None,
                        );
                    }
                };
                (
                    ResolutionMetadata::default(),
                    Some(doc),
                    Some(DocumentMetadata::default()),
                )
            }
            _ => return (ResolutionMetadata::from_error(ERROR_NOT_FOUND), None, None),
        }
    }
}

Required Methods§

source

fn resolve<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Option<Document>, Option<DocumentMetadata>)> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Resolve a DID

i.e. the resolve function from DID Core and DID Resolution.

Provided Methods§

source

fn resolve_representation<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, did: &'life1 str, input_metadata: &'life2 ResolutionInputMetadata ) -> Pin<Box<dyn Future<Output = (ResolutionMetadata, Vec<u8>, Option<DocumentMetadata>)> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Resolve a DID in a given representation

i.e. the resolveRepresentation function from DID Core and DID Resolution.

source

fn dereference<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _primary_did_url: &'life1 PrimaryDIDURL, _did_url_dereferencing_input_metadata: &'life2 DereferencingInputMetadata ) -> Pin<Box<dyn Future<Output = Option<(DereferencingMetadata, Content, ContentMetadata)>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Dereference a DID URL.

DID methods implement this function to support dereferencing DID URLs with paths and query strings. Callers should use dereference instead of this function.

source

fn to_did_method(&self) -> Option<&dyn DIDMethod>

Cast the resolver as a DIDMethod, if possible.

Implementors§

source§

impl DIDResolver for DIDExample

Available on crate feature example only.
source§

impl DIDResolver for HTTPDIDResolver

Available on crate feature http only.
source§

impl<'a> DIDResolver for DIDMethods<'a>

source§

impl<'a> DIDResolver for SeriesResolver<'a>