OpenAgentID documentation
Source referencesRust module referenceoas-did

oas-did · did

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

Source: oas/oas/oas-did/src/did.rs. SHA-256: f25910f0bb7b9f5b506496b7757f690bd5c76826b61d953f1e50a6784d019022.

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.

did::OasDid

A parsed and validated did:oas decentralized identifier.

An [OasDid] guarantees that the contained identifier conforms to the syntax rules in OAS Specification §3.1. It is the primary type for working with OAS identifiers throughout the SDK.

Format

did:oas:<namespace>:<kind>:<identifier>

For the compound kind agent:instance:

did:oas:<namespace>:agent:instance:<identifier>

Examples

use oas_did::OasDid;
use std::str::FromStr;

let did = OasDid::from_str("did:oas:acme:agent:support-bot-42").unwrap();
assert_eq!(did.namespace(), "acme");
assert_eq!(did.kind(), oas_did::kind::EntityKind::Agent);
assert_eq!(did.identifier(), "support-bot-42");
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct OasDid {

}

Source line: 43.

did::OasDid::new

Creates a new [OasDid] with validation.

Arguments

  • namespace - The organizational namespace.
  • kind - The entity kind.
  • identifier - The unique identifier within the namespace and kind.

Returns

A validated [OasDid].

Errors

Returns a [DidError] if the namespace or identifier fails validation.

Examples

use oas_did::OasDid;
use oas_did::kind::EntityKind;

let did = OasDid::new("acme", EntityKind::Agent, "my-bot").unwrap();
assert_eq!(did.to_string(), "did:oas:acme:agent:my-bot");
pub fn new(namespace: &str, kind: EntityKind, identifier: &str) -> Result<Self, DidError>;

Source line: 75.

did::OasDid::namespace

Returns the namespace component.

pub fn namespace(&self) -> &str;

Source line: 86.

did::OasDid::kind

Returns the entity kind.

pub fn kind(&self) -> EntityKind;

Source line: 91.

did::OasDid::identifier

Returns the identifier component.

pub fn identifier(&self) -> &str;

Source line: 96.

did::OasDid::is_root

Returns true if this is a root entity (HMR, MHR, or ENR).

Root entities have no parent and no lineage section.

pub fn is_root(&self) -> bool;

Source line: 103.

did::OasDid::as_str

Returns the full DID string representation.

pub fn as_str(&self) -> String;

Source line: 108.

On this page