Skip to main content

Module stream

Module stream 

Source
Expand description

Blocking stream read and write over a caller-supplied transport (ADR-041 § 8).

hurray-io is async and generic over Tokio’s traits; the C ABI is blocking and returns status codes. What connects them is not a bridge but a shared foundation: hurray-io’s sans-io core is a state machine over bytes, and these handles are a second driver for it — the first being the Tokio one. No runtime is linked into a C consumer’s binary.

The division of labour:

  • the core decides what bytes it needs next and never blocks,
  • the transport (HurrayTransport) moves those bytes and MAY block,
  • these handles carry counts between the two.

That is what lets the blocking contract live entirely in the caller’s callbacks.

Scope: tensors and composites. The reader offers both views of the same bytes — hurray_reader_next_tensor in wire order, where a composite head is the buffer-less tensor it is on the wire, and hurray_reader_next_item assembled, where a composite arrives whole. One core, two views, which is what step 2 of ADR-041 set up. File containers are crate::file’s: they are addressed rather than consumed, so they drive the random-access core over the vtable’s read_at and size callbacks.

Structs§

HurrayIoSlice
One borrowed payload: a pointer and a length.
HurrayReader
Opaque handle to a blocking stream reader.
HurrayReaderOptions
Resource limits and transport assumptions for a reader.
HurrayTransport
A caller-supplied byte transport: a context pointer plus the callbacks that move bytes.
HurrayWriter
Opaque handle to a blocking stream writer.
HurrayWriterOptions
Transport assumptions for a writer.

Functions§

hurray_reader_destroy⚠
Destroys a reader, releases its transport context, and writes null through handle.
hurray_reader_new⚠
Creates a reader over transport.
hurray_reader_next_item⚠
Reads the next item: one tensor, or a composite and everything under it.
hurray_reader_next_tensor⚠
Reads the next tensor, blocking in the transport’s read callback as needed.
hurray_writer_destroy⚠
Destroys a writer, releases its transport context, and writes null through handle.
hurray_writer_new⚠
Creates a writer over transport.
hurray_writer_write_composite⚠
Writes a composite — its head, then every member, nested ones included — as one item.
hurray_writer_write_tensor⚠
Writes one tensor — its descriptor then its payloads — blocking in the transport’s write callback as needed.

Type Aliases§

HurrayTransportReadAtFn
Reads up to len bytes from absolute offset offset into dst, reporting the count through out_filled.
HurrayTransportReadFn
Reads up to len bytes into dst, reporting the count through out_filled.
HurrayTransportReleaseFn
Releases the transport’s context pointer when the handle that owns it is destroyed.
HurrayTransportSizeFn
Reports the total size of the input in bytes.
HurrayTransportWriteFn
Writes up to len bytes from src, reporting the count through out_written.