pub struct IoBuffers<Buffers> { /* private fields */ }Expand description
An owned scatter/gather package with I/O vectors prepared once at construction. The vector allocation and source owners are reused between operations; payload bytes are never copied.
use base_scheduler::{IoBuffers, IoBufSequence};
let mut buffers = IoBuffers::new([b"header".to_vec(), b"body".to_vec()]);
// After an operation returns its owner and reports a short transfer:
buffers.advance(7);
assert_eq!(buffers.buffer(0), b"ody");
let [header, body] = buffers.into_inner();
assert_eq!(header, b"header");
assert_eq!(body, b"body");Borrowed I/O vectors cannot outlive the package, even when copied:
use base_scheduler::{IoBuffers, IoBufSequence};
let vector = {
let buffers = IoBuffers::new([vec![1, 2]]);
buffers.io_slices().unwrap()[0]
};
assert_eq!(&*vector, &[1, 2]);Implementations§
Source§impl<Buffers: IoBufSequence> IoBuffers<Buffers>
impl<Buffers: IoBufSequence> IoBuffers<Buffers>
Sourcepub fn new(buffers: Buffers) -> Self
pub fn new(buffers: Buffers) -> Self
Prepare one vector per source range, retaining the complete sequence owner. This allocates vector storage once; subsequent moves, borrows, and advancement do not allocate.
Panics on Windows if an individual byte range exceeds the IoSlice/IoSliceMut 4 GiB limit.
Sourcepub fn advance(&mut self, bytes: usize)
pub fn advance(&mut self, bytes: usize)
Skip completed bytes after an operation has returned the package. Fully consumed vectors are skipped; only the first partially consumed vector is adjusted. Source owners and their original ranges are preserved.
Panics without changing the package if bytes exceeds the remaining length. Advancing by zero also skips leading empty vectors. Schedulers never advance the package automatically.
Sourcepub fn into_inner(self) -> Buffers
pub fn into_inner(self) -> Buffers
Recover the original sequence, including fully consumed buffers and their original ranges.