Skip to main content

IoBuf

Trait IoBuf 

Source
pub unsafe trait IoBuf:
    Default
    + Send
    + Sync
    + 'static {
    // Required methods
    fn stable_ptr(&self) -> *const u8;
    fn bytes_init(&self) -> usize;
    fn bytes_total(&self) -> usize;
}
Expand description

A buffer an owned write takes: memory at an address that does not move while the runtime holds the buffer, whose first bytes_init bytes are written.

Implemented for Vec<u8> and AlignedBuf; a caller’s own type (a shared byte buffer, memory of a registered region) may implement it too. It is Send and Sync, since the runtime may hand it to another thread and several zero-copy sends read it at once, and its Default is the empty buffer a call gives back when the caller’s own cannot come back.

§Safety

stable_ptr is never null and points at bytes_total bytes of memory, the first bytes_init of them initialized, which stay valid and in place while the value is not used through &mut or dropped, even when the value itself moves: the kernel may read them after the value moved into the runtime. bytes_init() <= bytes_total().

Required Methods§

Source

fn stable_ptr(&self) -> *const u8

The address of the buffer’s first byte.

Source

fn bytes_init(&self) -> usize

How many bytes from the start hold data: what a write sends.

Source

fn bytes_total(&self) -> usize

How many bytes the buffer’s memory holds in all.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl IoBuf for Vec<u8>

Implementors§