Expand description
Owned-buffer I/O helpers shared by every runtime backend.
The runtime adapters (rt::tokio, rt::smol, and the native rt::compio
path) all speak compio’s owned-buffer read/write contract. Two pieces of
that contract are fiddly enough that duplicating them per backend invites
drift:
- declaring how many bytes a read initialized in a buffer’s spare capacity,
which is the workspace’s single owned-buffer
unsafeoperation (fill_read); and - building borrowed
IoSlices over an owned vectored buffer for onewritev(with_vectored_slices).
Centralizing both here gives each backend one call site instead of its own
copy, and keeps the lone set_buf_init unsafe behind a single documented
contract rather than repeated in every adapter.
Like tcp, this module encapsulates its unsafe behind a safe API, so it
opts back into unsafe_code that the crate otherwise denies.
Constants§
- COPY_
OUT_ THRESHOLD - Frame-size threshold below which a received frame is copied out of the shared read slab into a right-sized allocation instead of being frozen in place.
- READ_
SLAB_ SIZE - Size of a read scratch slab.
Functions§
- fill_
read - Read into an owned buffer’s spare capacity, then declare the bytes written as initialized.
- take_
read_ ⚠buffer - Take a read-sized scratch buffer from the front of
stash, leaving the remaining tail instashto hand out on the next call. - with_
vectored_ slices - Build borrowed
IoSlices over the initialized bytes of each buffer in an owned vectored buffer and hand them toffor a single vectored write.