oas-resolve · memory
Declared module signatures, types, configuration, and source documentation.
Source: oas/oas/oas-resolve/src/memory.rs. SHA-256: f949fec8753d0e034fc1bd52e2b9f986d0a5b941fc1d5aed7278088416db697d.
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.
memory::InMemoryResolver
An in-memory DID resolver for testing and development.
Stores documents in a thread-safe HashMap. Documents are
registered via register and
resolved via the [Resolver] trait.
Thread Safety
Uses RwLock for interior mutability, allowing concurrent reads
with exclusive writes.
Examples
use oas_resolve::memory::InMemoryResolver;
use oas_resolve::resolver::Resolver;
use oas_document::builder::DocumentBuilder;
use oas_document::conformance::ConformanceLevel;
use oas_crypto::keypair::OasKeyPair;
# tokio_test::block_on(async {
let keypair = OasKeyPair::generate();
let doc = DocumentBuilder::new("did:oas:test:hmr:alice", "hmr")
.conformance_level(ConformanceLevel::L1)
.add_verification_method(&keypair)
.build_and_sign(&keypair, "2026-01-15T00:00:00Z")
.unwrap();
let resolver = InMemoryResolver::new();
resolver.register(doc);
let resolved = resolver.resolve("did:oas:test:hmr:alice").await;
assert!(resolved.is_ok());
# });pub struct InMemoryResolver {
}Source line: 52.
memory::InMemoryResolver::new
Creates an empty in-memory resolver.
pub fn new() -> Self;Source line: 58.
memory::InMemoryResolver::register
Registers a document in the resolver.
The document is stored under its id field. If a document
with the same ID already exists, it is replaced.
Arguments
doc- The document to register.
pub fn register(&self, doc: OasDocument);Source line: 72.
memory::InMemoryResolver::len
Returns the number of registered documents.
pub fn len(&self) -> usize;Source line: 79.
memory::InMemoryResolver::is_empty
Returns true if no documents are registered.
pub fn is_empty(&self) -> bool;Source line: 84.
memory::InMemoryResolver::remove
Removes a document from the resolver.
Arguments
did- The DID of the document to remove.
Returns
The removed document, if it existed.
pub fn remove(&self, did: &str) -> Option<OasDocument>;Source line: 97.