pub trait ControllerProvider {
    type Controller<'a>: Controller
       where Self: 'a;

    // Required method
    async fn get_controller<'a>(
        &'a self,
        id: &'a Iri,
    ) -> Result<Option<Self::Controller<'a>>, ControllerError>;

    // Provided methods
    async fn require_controller<'a>(
        &'a self,
        id: &'a Iri,
    ) -> Result<Self::Controller<'a>, ControllerError> { ... }
    async fn allows_verification_method<'a>(
        &'a self,
        controller_id: &'a Iri,
        method_id: &'a Iri,
        proof_purposes: ProofPurposes,
    ) -> Result<bool, ControllerError> { ... }
    async fn ensure_allows_verification_method<'a>(
        &'a self,
        controller_id: &'a Iri,
        method_id: &'a Iri,
        proof_purpose: ProofPurpose,
    ) -> Result<(), ProofValidationError> { ... }
}
Expand description

Controller provider.

A provider is in charge of retrieving the verification method controllers from their identifiers.

Required Associated Types§

source

type Controller<'a>: Controller where Self: 'a

Controller reference type.

Required Methods§

source

async fn get_controller<'a>( &'a self, id: &'a Iri, ) -> Result<Option<Self::Controller<'a>>, ControllerError>

Returns the controller with the given identifier, if it can be found.

Provided Methods§

source

async fn require_controller<'a>( &'a self, id: &'a Iri, ) -> Result<Self::Controller<'a>, ControllerError>

Returns the controller with the given identifier, or fails if it cannot be found.

source

async fn allows_verification_method<'a>( &'a self, controller_id: &'a Iri, method_id: &'a Iri, proof_purposes: ProofPurposes, ) -> Result<bool, ControllerError>

Checks that the controller identified by controller_id allows the use of the verification method method_id with the given proof purposes.

source

async fn ensure_allows_verification_method<'a>( &'a self, controller_id: &'a Iri, method_id: &'a Iri, proof_purpose: ProofPurpose, ) -> Result<(), ProofValidationError>

Ensures that the controller identified by controller_id allows the use of the verification method method_id with the given proof purposes.

Contrarily to the allows_verification_method function, this function returns an error if one of the input proof purposes is not allowed.

Object Safety§

This trait is not object safe.

Implementors§