Expand description
Async I/O traits, adapters, and capability infrastructure.
This module provides minimal AsyncRead and AsyncWrite traits, a safe
ReadBuf type, and common adapters and extension futures. The design
mirrors std::io and futures::io but is intentionally small and cancel-aware.
§I/O Capability Model
Asupersync uses explicit capability-based I/O access. The IoCap trait
defines the I/O capability boundary - tasks can only perform I/O when they
have access to an implementation:
- Production: Real I/O via reactor (epoll/kqueue/IOCP)
- Lab: Virtual I/O for deterministic testing (see
LabIoCap)
§Cancel Safety
§Read operations
poll_readis cancel-safe (partial data is discarded by the caller).read_exactis not cancel-safe (partial state is retained).read_to_endis cancel-safe (collected bytes remain in the buffer).read_to_stringis not fully cancel-safe (bytes are preserved, but a partial UTF-8 sequence at the end may be lost if cancelled).
§Write operations
poll_writeis cancel-safe (partial writes are OK).write_allis not cancel-safe (partial writes may occur).WritePermitis cancel-safe (uncommitted data is discarded on drop).flushandshutdownare cancel-safe (can retry).
§Copy operations
copyis cancel-safe (bytes already written remain committed).copy_bufis cancel-safe (bytes already written remain committed).copy_with_progressis cancel-safe (progress callback is accurate).copy_bidirectionalis cancel-safe (both directions can be partially complete).
Re-exports§
pub use ext::AsyncReadExt;pub use ext::AsyncReadVectoredExt;pub use ext::ReadExact;pub use ext::ReadToEnd;pub use ext::ReadToString;pub use ext::ReadU8;pub use ext::ReadVectored;pub use ext::AsyncWriteExt;pub use ext::Buf;pub use ext::Flush;pub use ext::Shutdown;pub use ext::WriteAll;pub use ext::WriteAllBuf;pub use ext::WriteU8;pub use ext::WriteVectored;pub use cap::IoCap;pub use cap::IoNotAvailable;pub use cap::LabIoCap;
Modules§
- cap
- I/O capability trait for explicit capability-based I/O access.
- ext
- Extension traits and future adapters for async I/O.
Structs§
- BufReader
- Async buffered reader.
- BufWriter
- Async buffered writer.
- Chain
- Chain two readers.
- Copy
- Future for the
copyfunction. - Copy
Bidirectional - Future for the
copy_bidirectionalfunction. - CopyBuf
- Future for the
copy_buffunction. - Copy
With Progress - Future for the
copy_with_progressfunction. - Lines
- Iterator over the lines of an
AsyncBufRead. - ReadBuf
- Buffer for reading data.
- Read
Half - The read half of a split stream.
- Split
Stream - A wrapper around a stream that allows splitting into read/write halves.
- Take
- Take at most
limitbytes from a reader. - Write
Half - The write half of a split stream.
- Write
Permit - A permit for cancel-safe writes.
Enums§
- Seek
From - Enumeration of possible methods to seek within an I/O object.
Traits§
- Async
BufRead - Buffered read trait for efficient copy operations.
- Async
Read - Async non-blocking read.
- Async
Read Vectored - Async non-blocking read into multiple buffers (vectored I/O).
- Async
Seek - Trait for async seeking.
- Async
Write - Async non-blocking write.
- Async
Write Vectored - Async non-blocking write from multiple buffers (vectored I/O).
Functions§
- copy
- Copy all data from a reader to a writer.
- copy_
bidirectional - Bidirectional copy between two streams.
- copy_
buf - Copy all data from a buffered reader to a writer.
- copy_
with_ progress - Copy all data from a reader to a writer with progress reporting.
- split
- Convenience function to split a stream into read and write halves.