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>
impl<T, E: RingOp<T>> Ring<T, E>
Sourcepub fn new(ring: IoUring, ctx: T) -> Self
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.
Sourcepub unsafe fn register_buffers(&self, iovecs: &[iovec]) -> Result<()>
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.
Sourcepub fn register_files(&self, fds: &[RawFd]) -> Result<()>
pub fn register_files(&self, fds: &[RawFd]) -> Result<()>
Registers file descriptors as fixed for I/O with the kernel.
Operations may then use types::Fixed(index) for index in fds to refer to the
registered file descriptor.
-1 values can be used as slots for kernel managed fixed file descriptors (created by
open operation).
Sourcepub fn submit(&mut self) -> Result<()>
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.
Sourcepub fn submit_and_wait(
&mut self,
want: usize,
timeout: Option<Duration>,
) -> Result<usize>
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.
Sourcepub fn process_completions(&mut self) -> Result<()>
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.
Trait Implementations§
Source§impl<T, E: RingOp<T>> RingAccess for Ring<T, E>
impl<T, E: RingOp<T>> RingAccess for Ring<T, E>
Source§fn push(&mut self, op: E) -> Result<()>
fn push(&mut self, op: E) -> Result<()>
Pushes an operation to the submission queue.
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.