Skip to main content

hurray_reader_next_tensor

Function hurray_reader_next_tensor 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hurray_reader_next_tensor( handle: *mut HurrayReader, out_tensor: *mut *mut HurrayTensor, ) -> HurrayStatus
Expand description

Reads the next tensor, blocking in the transport’s read callback as needed.

Returns:

  • HURRAY_OK — *out_tensor is a new HurrayTensor, to be released with hurray_tensor_destroy.
  • HURRAY_END_OF_STREAM — input ended cleanly at a tensor boundary. *out_tensor is untouched. Positive, because this is how a stream ends, not a failure.
  • HURRAY_ERR_UNEXPECTED_EOF — input ended inside a descriptor or a buffer.
  • Whatever status the read callback returned, if it failed. The reader’s position is intact in that case — the transport contract says a failing callback moved no bytes — so the same call MAY be retried and will resume mid-tensor rather than restart it.

A composite head arrives as the buffer-less tensor it is on the wire, and its members as the tensors that follow it. Use hurray_reader_next_item to have them assembled into one walkable item instead.

Every buffer in the returned tensor points at memory the read core allocated at the alignment its buffer handle declares, and the transport wrote into it directly — so a SIMD load on it is sound, and no copy of the payload happened after that write.

§Safety

  • handle MUST point to a live HurrayReader.
  • out_tensor MUST be a valid, non-null, writable pointer.