uor-foundation 0.1.2

UOR Foundation — typed Rust traits for the complete ontology. Import and implement.
Documentation
// @generated by uor-crate from uor-ontology — do not edit manually

//! `u/` namespace — Content-addressable identifiers represented as Braille strings. Each address is a sequence of Braille glyphs encoding a unique content-derived identifier..
//!
//! Space: Kernel

use crate::Primitives;

/// A content-addressable identifier represented as a Braille string. Each Address uniquely identifies a piece of content via its Braille-encoded hash.
pub trait Address<P: Primitives> {
    /// The Braille string representation of an address. Each character in the string is a Braille glyph (cell).
    fn glyph(&self) -> &P::String;
    /// The number of Braille glyphs in an address string.
    fn length(&self) -> P::NonNegativeInteger;
    /// The datum that this address references. Inverse of schema:glyph.
    fn addresses(&self) -> &P::String;
    /// The content hash of this address. Format: (blake3|sha256) colon followed by 64 lowercase hex characters. The algorithm prefix must match u:digestAlgorithm.
    fn digest(&self) -> &P::String;
    /// The hash algorithm used to produce u:digest. Allowed values: 'blake3' (primary), 'sha256' (secondary).
    fn digest_algorithm(&self) -> &P::String;
    /// The canonical byte serialisation of the addressed datum, per Amendment 43 section 2: header(k) || le_bytes(x, k+1). This is the exact byte string hashed to produce u:digest.
    fn canonical_bytes(&self) -> &P::String;
    /// The quantum level n of this address. The address encodes a datum in R_n = Z/(2^n)Z.
    fn quantum(&self) -> P::PositiveInteger;
}

/// A single Braille cell encoding 6 bits of an address. The bijection between Braille cells and 6-bit values is the foundational encoding of the UOR content-addressing scheme.
pub trait Glyph<P: Primitives> {
    /// The Unicode codepoint of a Braille glyph. Braille glyphs occupy the range U+2800–U+28FF.
    fn codepoint(&self) -> P::NonNegativeInteger;
    /// The 6-bit integer value (0–63) encoded by this Braille glyph. The bijection maps each of the 64 Braille patterns to a unique 6-bit value.
    fn byte_value(&self) -> P::NonNegativeInteger;
}