Ring

Struct 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

io_uring specific methods.

Source

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

Enable the ring.

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

Source§

impl Ring

Source

pub const fn config<'r>(queued_operations: usize) -> Config<'r>

Configure a Ring.

queued_operations is the number of queued operations, i.e. the number of concurrent A10 operation.

§Notes

A10 uses IORING_SETUP_SQPOLL by default for io_uring, 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. This can be disabled by Config::with_kernel_thread.

Source

pub fn new(queued_operations: usize) -> Result<Ring>

Create a new Ring with the default configuration.

For more configuration options see Config.

Source

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

Returns the SubmissionQueue used by this ring.

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

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. When using io_uring it also 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 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>,

Source§

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

Source§

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.