Struct a10::io::ReadBufPool

source ·
pub struct ReadBufPool { /* private fields */ }
Expand description

A read buffer pool.

This is a special buffer pool that shares its buffers with the kernel. The buffer pool is used by the kernel in read(2) and recv(2) like calls. Instead of user space having to select a buffer before issueing the read call, the kernel will select a buffer from the pool when it’s ready for reading. This avoids the need to have as many buffers as concurrent read calls.

As a result of this the returned buffer, ReadBuf, is somewhat limited. For example it can’t grow beyond the pool’s buffer size. However it can be used in write calls like any other buffer.

Implementations§

source§

impl ReadBufPool

source

pub fn new( sq: SubmissionQueue, pool_size: u16, buf_size: u32 ) -> Result<ReadBufPool>

Create a new buffer pool.

pool_size must be a power of 2, with a maximum of 2^15 (32768). buf_size is the maximum capacity of the buffer. Note that buffer can’t grow beyond this capacity.

source

pub fn get(&self) -> ReadBuf

Get a buffer reference to this pool.

This can only be used in read I/O operations, such as AsyncFd::read, but it won’t yet select a buffer to use. This is done by the kernel once it actually has data to write into the buffer. Before it’s used in a read call the returned buffer will be empty and can’t be resized, it’s effecitvely useless before a read call.

Trait Implementations§

source§

impl Clone for ReadBufPool

source§

fn clone(&self) -> ReadBufPool

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ReadBufPool

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.