Struct Ring

Source
pub struct Ring<D: Drive> { /* private fields */ }
Expand description

A low-level primitive for building an IO object on io-uring

Ring is a state machine similar to Submission, but it is designed to cycle through multiple IO events submitted to io-uring, rather than representing a single submission. Because of this, it is more low level, but it is suitable fro building an IO object like a File on top of io-uring.

Users writing code on top of Ring are responsible for making sure that it is correct. For example, when calling poll, users must ensure that they are in the proper state to submit whatever type of IO they would be attempting to submit. Additionally, users should note that Ring does not implement Drop. In order to cancel any ongoing IO, users are responsible for implementing drop to call cancel properly.

Implementations§

Source§

impl<D: Drive> Ring<D>

Source

pub fn new(driver: D) -> Ring<D>

Construct a new Ring on top of a driver.

Source

pub fn driver(&self) -> &D

Source

pub fn poll( self: Pin<&mut Self>, ctx: &mut Context<'_>, is_eager: bool, prepare: impl FnOnce(&mut SubmissionQueueEvent<'_>), ) -> Poll<Result<usize>>

Poll the ring state machine.

This accepts a callback, prepare, which prepares an event to be submitted to io-uring. This callback will only be called once during an iteration of ring’s state machine: once an event has been prepared, until it is completed or cancelled, a single ring instance will not prepare any additional events.

Source

pub fn cancel(&mut self, cancellation: Cancellation)

Cancel any ongoing IO with this cancellation.

Users are responsible for ensuring that the cancellation passed would be appropriate to clean up the resources of the running event.

Source

pub fn cancel_pinned(self: Pin<&mut Self>, cancellation: Cancellation)

Cancel any ongoing IO, but from a pinned reference.

This has the same behavior of as Ring::cancel.

Trait Implementations§

Source§

impl<D: Drive + Clone> Clone for Ring<D>

Source§

fn clone(&self) -> Ring<D>

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<D: Default + Drive> Default for Ring<D>

Source§

fn default() -> Ring<D>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<D> Freeze for Ring<D>
where D: Freeze,

§

impl<D> !RefUnwindSafe for Ring<D>

§

impl<D> Send for Ring<D>
where D: Send,

§

impl<D> Sync for Ring<D>
where D: Sync,

§

impl<D> Unpin for Ring<D>
where D: Unpin,

§

impl<D> !UnwindSafe for Ring<D>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

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.