Ring

Struct Ring 

Source
pub struct Ring<T, E: RingOp<T>> { /* private fields */ }
Expand description

An io_uring instance.

Implementations§

Source§

impl<T, E: RingOp<T>> Ring<T, E>

Source

pub fn new(ring: IoUring, ctx: T) -> Self

Creates a new ring with the provided io_uring instance and context.

The context T is a user defined value that will be passed to entries E once they complete. This value can be used to update state or perform additional actions as operations complete asynchronously.

Source

pub fn context(&self) -> &T

Returns a reference to the context value.

Source

pub fn context_mut(&mut self) -> &mut T

Returns a mutable reference to the context value.

Source

pub unsafe fn register_buffers(&self, iovecs: &[iovec]) -> Result<()>

Registers in-memory fixed buffers for I/O with the kernel.

§Safety

Callers must ensure that the iov_base and iov_len values are valid and will be valid until buffers are unregistered or the ring destroyed, otherwise undefined behaviour may occur.

See Submitter::register_buffers.

Source

pub fn push(&mut self, op: E) -> Result<()>

Pushes an operation to the submission queue.

Once completed, RingOp::complete will be called with the result.

Note that the operation is not submitted to the kernel until Ring::submit is called. If the submission queue is full, submit will be called internally to make room for the new operation.

See also Ring::submit.

Source

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

Submits all pending operations to the kernel.

If the ring can’t accept any more submissions because the completion queue is full, this will process completions and retry until the submissions are accepted.

See also Ring::process_completions.

Source

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

Submits all pending operations to the kernel and waits for completions.

If no timeout is passed this will block until want completions are available. If a timeout is passed, this will block until want completions are available or the timeout is reached.

Returns the number of completions received.

Source

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

Processes completions from the kernel.

This will process all completions currently available in the completion queue and invoke RingOp::complete for each completed operation.

Source

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

Drains the ring.

This will submit all pending operations to the kernel and process all completions until the ring is empty.

Auto Trait Implementations§

§

impl<T, E> Freeze for Ring<T, E>
where T: Freeze,

§

impl<T, E> RefUnwindSafe for Ring<T, E>

§

impl<T, E> Send for Ring<T, E>
where T: Send, E: Send,

§

impl<T, E> Sync for Ring<T, E>
where T: Sync, E: Sync,

§

impl<T, E> Unpin for Ring<T, E>
where T: Unpin, E: Unpin,

§

impl<T, E> UnwindSafe for Ring<T, E>
where T: UnwindSafe, E: UnwindSafe,

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.