Core Library

Substrate

The shared Rust library for CMN — data models, cryptographic verification, tree hashing, URI parsing, and JSON-schema validation used by Hypha and Synapse.

Core library for the Code Mycelial Network protocol. The default build performs no I/O and supports WASM; HTTP and archive support are opt-in.

What it does

Features

FeatureDescription
clientHTTP client via reqwest
client-safe-dnsClient with DNS filtering (adds tokio)
archive-ruzstdTar extraction with ruzstd (WASM-compatible)
archive-zstdTar extraction with zstd (native, faster)

Usage

[dependencies]
cmn-substrate = "0.4"

With the HTTP client and DNS filtering:

[dependencies]
cmn-substrate = { version = "0.4", features = ["client-safe-dns"] }
use substrate::{parse_uri, validate_schema, compute_blake3_hash};

// Parse a CMN URI
let hash = compute_blake3_hash(b"example");
let uri = parse_uri(&format!("cmn://example.com/{hash}"))?;

// Validate a document against its schema
let doc: serde_json::Value = serde_json::from_str(&json_str)?;
validate_schema(&doc)?;