Struct a10::Ring

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

This type represents the user space side of an io_uring.

An io_uring is split into two queues: the submissions and completions queue. The SubmissionQueue is public, but doesn’t provide many methods. The SubmissionQueue is used by I/O types in the crate to schedule asynchronous operations.

The completions queue is not exposed by the crate and only used internally. Instead it will wake the Futures exposed by the various I/O types, such as AsyncFd::write’s Write Future.

Implementations§

source§

impl Ring

source

pub const fn config<'r>(entries: u32) -> Config<'r>

Configure a Ring.

entries must be a power of two and in the range 1..=4096.

§Notes

A10 always uses IORING_SETUP_SQPOLL, which required Linux kernel 5.11 to work correctly. Furthermore before Linux 5.13 the user needs the CAP_SYS_NICE capability if run as non-root.

source

pub fn new(entries: u32) -> Result<Ring>

Create a new Ring with the default configuration.

For more configuration options see Config.

source

pub const fn submission_queue(&self) -> &SubmissionQueue

Returns the SubmissionQueue used by this ring.

The SubmissionQueue can be used to queue asynchronous I/O operations.

source

pub fn enable(&mut self) -> Result<()>

Enable the ring.

This only required when starting the ring in disabled mode, see Config::disable.

source

pub fn poll(&mut self, timeout: Option<Duration>) -> Result<()>

Poll the ring for completions.

This will wake all completed Futures with the result of their operations.

If a zero duration timeout (i.e. Some(Duration::ZERO)) is passed this function will only wake all already completed operations. It then guarantees to not make a system call, but it also means it doesn’t guarantee at least one completion was processed.

Trait Implementations§

source§

impl AsFd for Ring

source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
source§

impl Debug for Ring

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Ring

§

impl RefUnwindSafe for Ring

§

impl Send for Ring

§

impl Sync for Ring

§

impl Unpin for Ring

§

impl UnwindSafe for Ring

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, 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.