Skip to main content

encode_pre_encoded

Function encode_pre_encoded 

Source
pub fn encode_pre_encoded(
    metadata_js: JsValue,
    objects_js: Array,
    hash: Option<bool>,
) -> Result<Uint8Array, JsValue>
Expand description

Encode a complete Tensogram message from pre-encoded data objects.

Like crate::encode, but each object’s bytes are assumed already encoded by the caller (according to its descriptor’s pipeline) and are written verbatim. The library validates descriptor structure and any szip_block_offsets it finds but never runs the encoding pipeline. The hash is always recomputed from the caller’s bytes.

@param metadata_js - GlobalMetadata (JS object, version: 3 required). @param objects_js - Array of {descriptor, data}; each data must be a Uint8Array (opaque pre-encoded bytes). @param hash - Whether to stamp an xxh3 hash. Default true. @returns Full wire-format message as Uint8Array.