1use std::{future::Future, pin::Pin};
4
5use did::Did;
6use thiserror::Error;
7
8pub mod did;
9pub mod did_url;
10pub mod document;
11mod uri;
12
13pub type MethodFuture<T> = Pin<Box<dyn Future<Output = T> + Send + Sync>>;
15
16pub trait Method: Send + Sync {
17 fn method_name(&self) -> &'static str;
18 fn resolve(&self, did: Did) -> MethodFuture<Result<document::Document, ResolutionError>>;
19}
20
21#[derive(Error, Debug)]
22pub enum ResolutionError {
23 #[error("invalid DID")]
24 InvalidDid,
25 #[error("resolution failed: {0}")]
26 ResolutionFailed(String),
27 #[error("unsupported method")]
28 UnsupportedMethod,
29}