Expand description
A tensor handle: a descriptor and its buffers, paired structurally.
A tensor is a descriptor plus its buffers, and the C ABI used to make callers keep
the two halves paired by convention — a consumer that fetched one without the other
got either bytes it could not interpret or a description of bytes it did not have
(#174). HurrayTensor owns both, so
the pairing is structural: a caller holding the handle holds the description of the
bytes it points at.
Every path that produces a tensor produces this handle (ADR-043): a stream read, a
file read, and a native-protocol capsule, which carries one HurrayTensor * and no
context. One destroy call, and its internal order cannot be got wrong.
§Reading one
Check the version first, always — see hurray_tensor_abi_version. Every other
accessor assumes a caller that has done so.
§The owner
A producer’s buffers point into memory something else owns, and that something is
passed in as an opaque owner pointer with an owner_release callback. This crate
never interprets either, which is what lets hurray-python park a Python reference
there without any Python type reaching the C ABI. A tensor from a read carries
neither: it owns its buffers outright.
Structs§
- Hurray
Tensor - Opaque handle to a tensor: its descriptor and its buffers.
Functions§
- hurray_
tensor_ ⚠abi_ version - Reads the ABI version recorded by the producing build.
- hurray_
tensor_ ⚠buffers - Borrows the tensor’s buffer list.
- hurray_
tensor_ ⚠descriptor - Borrows the tensor’s descriptor handle.
- hurray_
tensor_ ⚠destroy - Destroys a tensor handle — its descriptor, every buffer it owns, and its owner
reference — then writes null through
handle. - hurray_
tensor_ ⚠new - Creates a
HurrayTensorfrom an encoded descriptor and a finished buffer list.
Type Aliases§
- Hurray
Owner Release Fn - Callback invoked exactly once by
hurray_tensor_destroyto release whatever keeps the tensor’s memory alive.