pub fn decode(
buf: &[u8],
restore_non_finite: Option<bool>,
verify_hash: Option<bool>,
) -> Result<DecodedMessage, JsValue>Expand description
Decode all objects from a complete Tensogram message.
Returns a DecodedMessage handle that owns the decoded data.
Use .object_data_f32(i) etc. to get zero-copy TypedArray views
into the decoded payloads.
@param buf - Raw .tgm message bytes
@param restore_non_finite - When true (default), decode writes canonical
NaN / +Inf / -Inf at positions recorded in
the frame’s mask companion. Set to false to
receive 0.0-substituted bytes as on disk.
@param verify_hash - When true, verify each data-object frame’s
inline xxh3 hash against the recomputed
digest. Default false (opt-in).
Integrity failures are returned as a
JsValue carrying a thrown js_sys::Error
with structured properties attached: name
is "MissingHashError" (when the per-frame
HASH_PRESENT flag is clear) or
"HashMismatchError" (when the slot
disagrees), and objectIndex /
expected / actual carry the structured
payload that the TS wrapper routes to
dedicated error classes. See
plans/DESIGN.md §“Integrity Hashing”.