OpenAgentID documentation
Source referencesRust module referenceoas-lineage

oas-lineage · provider

Declared module signatures, types, configuration, and source documentation.

Source: oas/oas/oas-lineage/src/provider.rs. SHA-256: c2b7bc7746cab041982221c20a525f6718b4728f1dfd142041c8fc51d0c81678.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

provider::DocumentProvider

A provider that resolves did:oas identifiers to [OasDocument]s.

This trait is the bridge between lineage verification and document resolution. The verification algorithm calls resolve() for each parent in the lineage chain.

Implementation Notes

  • Implementations SHOULD enforce per-hop timeouts internally.
  • Implementations SHOULD cache resolved documents to avoid redundant lookups.
  • Implementations MUST return the most recent valid document for a DID.

Examples

use oas_lineage::provider::{DocumentProvider, InMemoryProvider};
use oas_document::OasDocument;

let provider = InMemoryProvider::new();
// Empty provider returns an error for any DID
assert!(provider.resolve("did:oas:test:hmr:alice").is_err());
pub trait DocumentProvider {
    /// Resolves a `did:oas` identifier to its identity document.
    ///
    /// # Arguments
    ///
    /// * `did` - The `did:oas` identifier to resolve.
    ///
    /// # Returns
    ///
    /// The resolved [`OasDocument`], or a [`LineageError::ResolutionFailed`]
    /// if the document cannot be found or resolution fails.
    ///
    /// # Errors
    ///
    /// Returns [`LineageError::ResolutionFailed`] if the DID cannot be resolved.
    fn resolve(&self, did: &str) -> Result<OasDocument, LineageError>;
}

Source line: 38.

provider::InMemoryProvider

An in-memory document provider for testing and development.

Stores documents in a [HashMap] keyed by DID string. Useful for unit tests that need to verify lineage chains without network access.

Examples

use oas_lineage::provider::InMemoryProvider;
use oas_lineage::provider::DocumentProvider;

let mut provider = InMemoryProvider::new();
// Register documents, then use for lineage verification
assert_eq!(provider.len(), 0);
#[derive(Debug, Clone, Default)]
pub struct InMemoryProvider {

}

Source line: 73.

provider::InMemoryProvider::new

Creates an empty in-memory provider.

pub fn new() -> Self;

Source line: 79.

provider::InMemoryProvider::register

Registers a document in the provider.

The document is stored under its id field.

Arguments

  • doc - The document to register.
pub fn register(&mut self, doc: OasDocument);

Source line: 92.

provider::InMemoryProvider::len

Returns the number of registered documents.

pub fn len(&self) -> usize;

Source line: 97.

provider::InMemoryProvider::is_empty

Returns true if no documents are registered.

pub fn is_empty(&self) -> bool;

Source line: 102.

On this page