Skip to main content

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 can be read from (if this is an InputBuffer) or written to (if this is an OutputBuffer) using either user copy routines or Zircon system calls. If this is an OutputBuffer, any damage caused by bad addresses will be restricted to user addresses.

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.

NOTE: The returned segments can only be accessed using user copy routines or Zircon system calls (see the comment above for `peek_each_segment). The pointers returned are not valid for any non-zero sized access (see Rust’s std::ptr documentation).

Implementors§