Buffer

Trait Buffer 

Source
pub trait Buffer: Debug {
    // Required methods
    fn segments_count(&self) -> Result<usize, Errno>;
    fn peek_each_segment(
        &mut self,
        callback: &mut PeekBufferSegmentsCallback<'_>,
    ) -> Result<(), Errno>;

    // Provided method
    fn peek_all_segments_as_iovecs(
        &mut self,
    ) -> Result<IovecsRef<'_, iovec>, Errno> { ... }
}
Expand description

A buffer.

Provides the common implementations for input and output buffers.

Required Methods§

Source

fn segments_count(&self) -> Result<usize, Errno>

Returns the number of segments, if the buffer supports I/O directly to/from individual segments.

Source

fn peek_each_segment( &mut self, callback: &mut PeekBufferSegmentsCallback<'_>, ) -> Result<(), Errno>

Calls the callback with each segment backing this buffer.

Each segment is safe to read from (if this is an InputBuffer) or write to (if this is an OutputBuffer) without causing undefined behaviour.

Provided Methods§

Source

fn peek_all_segments_as_iovecs(&mut self) -> Result<IovecsRef<'_, iovec>, Errno>

Returns all the segments backing this Buffer.

Note that we use IovecsRef<'_> so that while IovecsRef is held, no other methods may be called on this Buffer since IovecsRef holds onto the mutable reference for this Buffer.

Each segment is safe to read from (if this is an InputBuffer) or write to (if this is an OutputBuffer) without causing undefined behaviour.

Implementors§