OpenAgentID documentation
Source referencesRust module referenceoas-wasm

oas-wasm · parse_did

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

Source: oas/oas/oas-wasm/src/parse_did.rs. SHA-256: 87786ad2c36cd290819ae24aeb347cb4201dfc2fa7d12acf33d8fd25dbc7c21f.

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.

parse_did::ParsedDid

Parsed DID components returned from WASM.

#[derive(Debug, Serialize)]
pub struct ParsedDid {
/// The full DID string.

pub did: String,
/// The namespace component.

pub namespace: String,
/// The entity kind.

pub kind: String,
/// The identifier component.

pub identifier: String
}

Source line: 11.

parse_did::ParseDidResult

Result of a DID parse operation, serialized as JSON.

#[derive(Debug, Serialize)]
pub struct ParseDidResult {
/// Whether the parse succeeded.

pub ok: bool,
/// The parsed DID (present if `ok` is true).

#[serde(skip_serializing_if = "Option::is_none")]
pub parsed: Option<ParsedDid>,
/// Error message (present if `ok` is false).

#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<String>
}

Source line: 24.

parse_did::parse_did

Parses a did:oas string and returns the result as JSON.

This is a synchronous, allocation-friendly function suitable for WASM.

Arguments

  • did - The DID string to parse.

Returns

A JSON string containing a [ParseDidResult].

Examples

use oas_wasm::parse_did::parse_did;

let result = parse_did("did:oas:test:agent:bot");
assert!(result.contains("\"ok\":true"));
assert!(result.contains("\"kind\":\"agent\""));

let result = parse_did("not-a-did");
assert!(result.contains("\"ok\":false"));
#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen)]
pub fn parse_did(did: &str) -> String;

Source line: 60.

On this page