Skip to main content

IoUring

Struct IoUring 

Source
pub struct IoUring { /* private fields */ }
Expand description

A Linux io_uring instance: one submission ring + one completion ring.

Implementations§

Source§

impl IoUring

Source

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

Create a ring sized for at least entries in-flight submissions.

Source

pub unsafe fn prep_read( &mut self, fd: i32, buf: *mut u8, len: u32, user_data: u64, ) -> bool

Queue a read(fd) of len bytes into buf, tagged with user_data. Returns false if the SQ is full.

§Safety

buf must point to len writable bytes and stay valid until the matching completion is reaped.

Source

pub unsafe fn prep_write( &mut self, fd: i32, buf: *const u8, len: u32, user_data: u64, ) -> bool

Queue a write(fd) of len bytes from buf, tagged with user_data. Returns false if the SQ is full.

§Safety

buf must point to len readable bytes and stay valid until the matching completion is reaped.

Source

pub fn prep_recv_multishot( &mut self, fd: i32, bgid: u16, user_data: u64, ) -> bool

Queue a multishot recv(fd) that draws its destination buffer from the provided-buffer group bgid (see IoUring::register_buf_ring): one SQE re-fires a completion per arrival, the kernel picking + reporting a buffer id each time, until it terminates (error / ENOBUFS, signalled by Completion::has_more returning false). No per-recv SQE, no read buffer to keep alive. Returns false if the SQ is full.

Source

pub fn prep_accept(&mut self, listen_fd: i32, user_data: u64) -> bool

Queue an accept on listen_fd; the accepted fd arrives as the completion’s res (already O_NONBLOCK | O_CLOEXEC). Returns false if the SQ is full.

Source

pub fn prep_nop(&mut self, user_data: u64) -> bool

Queue a no-op tagged with user_data (used to prove the round-trip). Returns false if the SQ is full.

Source

pub fn submit_and_wait(&mut self, wait_nr: u32) -> Result<u32>

Publish queued submissions and enter the kernel, optionally waiting for wait_nr completions. Returns the number of SQEs consumed.

Source

pub fn for_each_completion<F: FnMut(Completion)>(&mut self, f: F) -> u32

Reap every available completion, calling f for each; returns the count.

Source

pub fn register_buf_ring( &self, entries: u16, buf_size: u32, bgid: u16, ) -> Result<ProvidedBufRing>

Register a provided-buffer ring of entries (power of two) buffers of buf_size bytes each under group id bgid, for multishot prep_recv_multishot. The kernel draws a buffer per arrival and reports its id; the application recycles it via ProvidedBufRing::recycle. The registration is auto-released when the ring fd closes; the returned handle also unregisters + unmaps on drop.

Trait Implementations§

Source§

impl Drop for IoUring

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for IoUring

Auto Trait Implementations§

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.