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. Zero I/O, WASM-compatible.

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.1"

# With HTTP client
cmn-substrate = { version = "0.1", features = ["client-safe-dns"] }
use substrate::{parse_uri, validate_schema, compute_blake3_hash};

// Parse a CMN URI
let uri = parse_uri("cmn://example.com/b3.abc123")?;

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