pub fn decode_range(
buf: &[u8],
object_index: usize,
ranges: &BigUint64Array,
) -> Result<JsValue, JsValue>Expand description
Decode partial sub-tensor ranges from a single data object.
@param buf - Complete wire-format message bytes.
@param object_index - Zero-based index of the target object.
@param ranges - Flat BigUint64Array of [offset0, count0, offset1, count1, …]
pairs, in element units (not bytes). Empty array returns an empty result.
hash is checked against the payload before any range is decoded.
@returns { descriptor, parts: Uint8Array[] } — one raw-bytes view
per requested range, in request order. Callers (e.g. the TS
wrapper’s decodeRange) convert each Uint8Array into a
dtype-typed view.
Throws on out-of-range object index, unsupported filter (e.g.
shuffle), or bitmask dtype (matching the Rust-core contract).
Implementation note: the parts array is built manually with
Uint8Array::from rather than via to_js — serde_wasm_bindgen
serialises &[u8] as a plain JS Array<number> by default, and the
TS wrapper expects honest Uint8Array instances so that
typedArrayFor can wrap them zero-copy.