pub fn deref_did_url<'a>(
url: &DidUrl,
doc: &'a DidDocument,
) -> Option<DereferencedResource<'a>>Expand description
Dereference a DID URL against an already-resolved DID Document.
This is the “secondary” dereference step from W3C DID Core §7.2 — the document has already been resolved; this function extracts the specific resource identified by the URL’s fragment.
§Rules
- No fragment → returns the full document.
- Fragment matches a
verificationMethod[].id→ returns that VM. - Fragment matches a
service[].id→ returns that service. - Fragment matches nothing → returns
None.
Fragment comparison strips any leading # and is exact-string.
Per DID Core, fragment comparison is case-sensitive.
§Example
let url = DidUrl::parse("did:ndn:com:acme:alice#key-0").unwrap();
match deref_did_url(&url, doc) {
Some(ndn_security::did::url::DereferencedResource::VerificationMethod(vm)) => {
println!("Found key: {}", vm.id);
}
_ => {}
}