hurray_ffi/stream/mod.rs
1//! Blocking stream read and write over a caller-supplied transport (ADR-041 § 8).
2//!
3//! `hurray-io` is async and generic over Tokio's traits; the C ABI is blocking and returns
4//! status codes. What connects them is not a bridge but a shared foundation: `hurray-io`'s
5//! sans-io core is a state machine over bytes, and these handles are a second driver for
6//! it — the first being the Tokio one. No runtime is linked into a C consumer's binary.
7//!
8//! The division of labour:
9//!
10//! - the **core** decides what bytes it needs next and never blocks,
11//! - the **transport** ([`HurrayTransport`]) moves those bytes and MAY block,
12//! - these handles carry counts between the two.
13//!
14//! That is what lets the blocking contract live entirely in the caller's callbacks.
15//!
16//! Scope: tensors and composites. The reader offers both views of the same bytes —
17//! [`hurray_reader_next_tensor`] in wire order, where a composite head is the buffer-less
18//! tensor it is on the wire, and [`hurray_reader_next_item`] assembled, where a composite
19//! arrives whole. One core, two views, which is what step 2 of ADR-041 set up. File
20//! containers are
21//! [`crate::file`]'s: they are addressed rather than consumed, so they drive the
22//! random-access core over the vtable's `read_at` and `size` callbacks.
23
24mod reader;
25// `pub(crate)`: the file surface in `crate::file` is a second driver over the same vtable,
26// so it shares this internal.
27pub(crate) mod transport;
28mod writer;
29
30pub use reader::{
31 hurray_reader_destroy, hurray_reader_new, hurray_reader_next_item, hurray_reader_next_tensor,
32};
33pub use reader::{HurrayReader, HurrayReaderOptions};
34pub use transport::{
35 HurrayTransport, HurrayTransportReadAtFn, HurrayTransportReadFn, HurrayTransportReleaseFn,
36 HurrayTransportSizeFn, HurrayTransportWriteFn,
37};
38pub use writer::{
39 hurray_writer_destroy, hurray_writer_new, hurray_writer_write_composite,
40 hurray_writer_write_tensor,
41};
42pub use writer::{HurrayIoSlice, HurrayWriter, HurrayWriterOptions};