baseid_did/
resolution.rs

1//! DID resolution interface.
2
3use crate::document::DidDocument;
4
5/// Metadata returned alongside a resolved DID Document.
6#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct ResolutionMetadata {
9    /// The content type of the resolved document.
10    pub content_type: Option<String>,
11    /// Error code if resolution failed.
12    pub error: Option<String>,
13}
14
15/// Result of a DID resolution operation.
16#[derive(Debug, Clone)]
17pub struct ResolutionResult {
18    pub document: Option<DidDocument>,
19    pub metadata: ResolutionMetadata,
20}
21
22/// Trait for DID resolvers. Each DID method implements this trait.
23#[allow(async_fn_in_trait)]
24pub trait DidResolver: Send + Sync {
25    /// The DID method this resolver handles (e.g., "key", "web").
26    fn method(&self) -> &str;
27
28    /// Resolve a DID to its DID Document.
29    async fn resolve(&self, did: &str) -> baseid_core::Result<ResolutionResult>;
30}