Skip to main content

validate_buffer

Function validate_buffer 

Source
pub fn validate_buffer(
    buf: &[u8],
    level: Option<String>,
    check_canonical: bool,
) -> Result<String, JsValue>
Expand description

Validate a single Tensogram message buffer. Returns a JSON string matching the structure emitted by tensogram::validate::ValidationReport: { issues: [...], object_count: N, hash_verified: bool }.

The TypeScript wrapper parses this JSON once and exposes a typed ValidationReport. Keeping the bridge as a JSON string avoids lossy conversion of large integers and keeps the WASM surface language-neutral (it already matches the FFI contract).

@param buf - The wire-format bytes of a single message (not a file). @param level - One of "quick" / "default" / "checksum" / "full". None defaults to "default". @param check_canonical - When true, adds RFC 8949 ยง4.2 canonical CBOR key-ordering checks.