Skip to main content

hurray_writer_write_tensor

Function hurray_writer_write_tensor 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hurray_writer_write_tensor( handle: *mut HurrayWriter, descriptor: *const HurrayDescriptor, payloads: *const HurrayIoSlice, count: usize, ) -> HurrayStatus
Expand description

Writes one tensor — its descriptor then its payloads — blocking in the transport’s write callback as needed.

payloads MUST have one entry per buffer in the descriptor’s buffer table, in that order, each with the declared byte_size. The whole tensor is validated before a byte reaches the sink, so a mismatch is reported without putting a torn item on the wire.

Returns:

  • HURRAY_OK — the tensor is entirely written and the payload pointers are no longer held.
  • HURRAY_ERR_SINK_CLOSED — the sink stopped accepting bytes mid-tensor, so a truncated item is on the wire. The writer is poisoned: every later call fails, and a fresh writer over the same connection is not a recovery.
  • Whatever status the write callback returned, if it failed before any byte of this tensor reached the sink. Nothing was emitted, so the call MAY be retried. A failure after the first byte is reported as HURRAY_ERR_SINK_CLOSED instead, because at that point the damage is the same.

A composite is written with hurray_writer_write_composite; a composite head offered here is refused, because a head alone is not a valid tensor.

§Safety

  • handle MUST point to a live HurrayWriter and descriptor to a live HurrayDescriptor.
  • If count is non-zero, payloads MUST point to count readable HurrayIoSlice values, each describing memory readable for its own len bytes.
  • All of that memory MUST stay valid and unmodified until this call returns.