Stream Concepts
Capy organizes data flow around three concepts: ReadStream, WriteStream, and Stream. Partial operations and complete operations are fundamentally different things, and conflating them leads to bugs.
A socket might give you 47 bytes when you asked for 1024. That is not an error—it is the nature of the hardware. Capy’s stream concepts cover the partial case directly: read_some and write_some transfer whatever the hardware allows. The complete case is a composed algorithm, not a separate concept. read, write, read_at_least, and write_at_least loop over read_some or write_some until the buffer is satisfied or an error occurs.
What This Section Covers
-
Overview — What
ReadStream,WriteStream, andStreammodel, and why partial I/O needs its own concepts. -
Streams (Partial I/O) — The
ReadStreamandWriteStreamconcepts, and the type-erasedany_streamwrappers. -
Physical Isolation — Type erasure as a compilation firewall for transport-independent, testable I/O code.