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§
Sourcefn segments_count(&self) -> Result<usize, Errno>
fn segments_count(&self) -> Result<usize, Errno>
Returns the number of segments, if the buffer supports I/O directly to/from individual segments.
Sourcefn peek_each_segment(
&mut self,
callback: &mut PeekBufferSegmentsCallback<'_>,
) -> Result<(), Errno>
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§
Sourcefn peek_all_segments_as_iovecs(&mut self) -> Result<IovecsRef<'_, iovec>, Errno>
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.