use std::{
future::Future,
pin::Pin,
};
use did::Did;
use thiserror::Error;
pub mod did;
pub mod did_url;
pub mod document;
mod uri;
pub type MethodFuture<T> = Pin<Box<dyn Future<Output = T> + Send>>;
pub trait Method: Send + Sync {
fn method_name(&self) -> &'static str;
fn resolve(&self, did: Did) -> MethodFuture<Result<document::Document, ResolutionError>>;
}
#[derive(Error, Debug)]
pub enum ResolutionError {
#[error("invalid DID")]
InvalidDid,
#[error("document id does not match the resolved DID")]
DocumentMismatch,
#[error("resolution target is not permitted")]
TargetNotAllowed,
#[error("document exceeds the configured size limit")]
DocumentTooLarge,
#[error("resolution failed: {0}")]
ResolutionFailed(String),
#[error("unsupported method")]
UnsupportedMethod,
}