Module zerocopy

Module zerocopy 

Source
Expand description

Zero-copy I/O utilities.

This module provides utilities for minimizing buffer copies during I/O operations, improving performance for high-throughput terminal automation.

§Features

  • BytesBuffer: Reference-counted bytes for zero-copy slicing
  • VecWriter: Efficient vectored write batching
  • BorrowedView: Borrowed slice views with lifetime tracking

§Example

use rust_expect::util::zerocopy::{BytesBuffer, VecWriter};

// Create a buffer with zero-copy slicing
let mut buffer = BytesBuffer::new();
buffer.extend(b"hello world");

// Slice without copying
let slice = buffer.slice(0..5);
assert_eq!(&slice[..], b"hello");

// Batch multiple writes
let mut writer = VecWriter::new();
writer.push(&b"hello"[..]);
writer.push(&b" "[..]);
writer.push(&b"world"[..]);
let bytes = writer.freeze();
assert_eq!(&bytes[..], b"hello world");

Structs§

BytesBuffer
A reference-counted byte buffer that supports zero-copy slicing.
ReadPool
A read buffer that minimizes copies during async reads.
VecWriter
A writer that batches multiple small writes for vectored I/O.

Enums§

BorrowedView
A borrowed view of bytes with lifetime tracking.

Traits§

ZeroCopySource
Trait for types that can provide a zero-copy view of their contents.