oas-document · document
Declared module signatures, types, configuration, and source documentation.
Source: oas/oas/oas-document/src/document.rs. SHA-256: 586da29287fbfd0b63c9f78262aa79e5be3ad43b9af1cf6e7d3736bd92c0d468.
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.
document::OAS_CONTEXT
The OAS JSON-LD context URI.
pub const OAS_CONTEXT: &str;Source line: 28.
document::DID_CONTEXT
The W3C DID context URI.
pub const DID_CONTEXT: &str;Source line: 31.
document::ED25519_CONTEXT
The Ed25519 2020 suite context URI.
pub const ED25519_CONTEXT: &str;Source line: 34.
document::OAS_VERSION
The current OAS specification version.
pub const OAS_VERSION: &str;Source line: 37.
document::DocumentMetadata
Metadata section of an OAS Identity Document.
Examples
use oas_document::document::DocumentMetadata;
let meta = DocumentMetadata {
created: "2026-01-15T00:00:00Z".to_string(),
updated: None,
version: None,
};#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DocumentMetadata {
/// ISO 8601 creation timestamp (required).
pub created: String,
/// ISO 8601 last update timestamp (optional).
#[serde(skip_serializing_if = "Option::is_none")]
pub updated: Option<String>,
/// Semantic version of this entity's definition (optional).
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>
}Source line: 53.
document::OasDocument
An OAS Identity Document as defined in OAS Specification §5.
This is the canonical representation of an autonomous entity's identity, extending the W3C DID Document with OAS-specific properties.
Examples
use oas_document::OasDocument;
let json = r#"{
"@context": ["https://www.w3.org/ns/did/v1", "https://w3id.org/security/suites/ed25519-2020/v1", "https://openagent.id/ns/oas/v1"],
"id": "did:oas:test:hmr:alice",
"controller": "did:oas:test:hmr:alice",
"verificationMethod": [{"id": "did:oas:test:hmr:alice#key-1", "type": "Ed25519VerificationKey2020", "controller": "did:oas:test:hmr:alice", "publicKeyMultibase": "zTest"}],
"authentication": ["did:oas:test:hmr:alice#key-1"],
"oasVersion": "1.0.0",
"kind": "hmr",
"conformanceLevel": "L1",
"sequence": 1,
"metadata": {"created": "2026-01-15T00:00:00Z"}
}"#;
let doc: OasDocument = serde_json::from_str(json).unwrap();
assert_eq!(doc.id, "did:oas:test:hmr:alice");#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OasDocument {
/// JSON-LD contexts. MUST include the OAS context.
#[serde(rename = "@context")]
pub context: Vec<String>,
/// The `did:oas` identifier.
pub id: String,
/// DID of the controlling entity.
pub controller: String,
/// At least one Ed25519VerificationKey2020.
pub verification_method: Vec<VerificationMethod>,
/// References to keys authorized for authentication.
pub authentication: Vec<String>,
/// References to keys authorized for assertions.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub assertion_method: Vec<String>,
/// References to keys authorized for capability invocation.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub capability_invocation: Vec<String>,
/// References to keys authorized for capability delegation.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub capability_delegation: Vec<String>,
/// Service endpoints.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub service: Vec<ServiceEndpoint>,
/// OAS specification version (currently `"1.0.0"`).
pub oas_version: String,
/// Entity kind from the taxonomy.
pub kind: String,
/// Human-readable name (max 256 chars).
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// Human-readable description (max 4096 chars).
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
/// Lineage information (required for L1+ non-root entities).
#[serde(skip_serializing_if = "Option::is_none")]
pub lineage: Option<LineageSection>,
/// Governance section (ENR entities only).
/// Tracks which MHR governs this enterprise identity, epoch, and transition history.
#[serde(skip_serializing_if = "Option::is_none")]
pub governance: Option<GovernanceSection>,
/// Conformance level: L0, L1, or L2.
pub conformance_level: ConformanceLevel,
/// Lifecycle status.
#[serde(skip_serializing_if = "Option::is_none")]
pub lifecycle_status: Option<LifecycleStatus>,
/// Monotonically increasing version counter (starting at 1).
pub sequence: u64,
/// Document metadata.
pub metadata: DocumentMetadata,
/// Document proof (Ed25519Signature2020).
#[serde(skip_serializing_if = "Option::is_none")]
pub proof: Option<DocumentProof>,
/// Whether this identity has been revoked.
#[serde(skip_serializing_if = "Option::is_none")]
pub revoked: Option<bool>,
/// Timestamp of revocation.
#[serde(skip_serializing_if = "Option::is_none")]
pub revoked_at: Option<String>,
// ── Extended Identity Sections (OAS §5.8–§5.16) ──────────────────
/// Profile / presentation data (§5.8): avatar, tagline, categories.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub profile: Option<ProfileSection>,
/// Contact directory (§5.9): phones, emails, socials, websites.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub contact: Option<ContactSection>,
/// Calendar & scheduling (§5.10): booking links, office hours.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub calendar: Option<CalendarSection>,
/// Operational specification (§5.11): SLA, rate limits, formats.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub operational: Option<OperationalSection>,
/// Pricing & economics (§5.12): cost model, billing, free tier.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pricing: Option<PricingSection>,
/// Interoperability (§5.13): protocols, API schemas, auth methods.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub interoperability: Option<InteroperabilitySection>,
/// Reputation summary (§5.14): interactions, endorsements, uptime.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub reputation: Option<ReputationSection>,
/// Compliance & jurisdiction (§5.15): certifications, policy URLs.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub compliance: Option<ComplianceSection>,
/// Relationships & affiliations (§5.16): org structure, partnerships.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub relationships: Option<RelationshipsSection>
}Source line: 93.
document::OasDocument::default_context
Returns the default JSON-LD context array for OAS documents.
pub fn default_context() -> Vec<String>;Source line: 214.
document::OasDocument::is_root
Returns true if this document represents a root entity (HMR, MHR, or ENR).
pub fn is_root(&self) -> bool;Source line: 223.
document::OasDocument::is_revoked
Returns true if this document has been revoked.
pub fn is_revoked(&self) -> bool;Source line: 228.
document::OasDocument::canonical_digest
Computes the canonical BLAKE3 commitment for this complete document.
The digest covers the RFC 8785 canonical JSON representation, including the document proof and all status, relationship, key, and lineage fields. Lineage proofs bind this value to the authenticated parent state used at issuance time.
Returns
A lowercase blake3:-prefixed digest.
Errors
Returns [DocumentError::Crypto] if canonicalization fails.
pub fn canonical_digest(&self) -> Result<String, DocumentError>;Source line: 246.
document::OasDocument::primary_public_key_multibase
Returns the primary public key multibase string, if available.
Looks for the first verification method's public key.
pub fn primary_public_key_multibase(&self) -> Option<&str>;Source line: 258.
document::OasDocument::find_verification_method
Finds a verification method by its full ID or fragment.
pub fn find_verification_method(&self, id_or_fragment: &str) -> Option<&VerificationMethod>;Source line: 265.