1use std::{
4 future::Future,
5 pin::Pin,
6};
7
8use did::Did;
9use thiserror::Error;
10
11pub mod did;
12pub mod did_url;
13pub mod document;
14mod uri;
15
16pub type MethodFuture<T> = Pin<Box<dyn Future<Output = T> + Send>>;
18
19pub trait Method: Send + Sync {
20 fn method_name(&self) -> &'static str;
21 fn resolve(&self, did: Did) -> MethodFuture<Result<document::Document, ResolutionError>>;
22}
23
24#[derive(Error, Debug)]
25pub enum ResolutionError {
26 #[error("invalid DID")]
27 InvalidDid,
28 #[error("document id does not match the resolved DID")]
31 DocumentMismatch,
32 #[error("resolution target is not permitted")]
34 TargetNotAllowed,
35 #[error("document exceeds the configured size limit")]
36 DocumentTooLarge,
37 #[error("resolution failed: {0}")]
40 ResolutionFailed(String),
41 #[error("unsupported method")]
42 UnsupportedMethod,
43}