Builder

Struct Builder 

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

Builder API that can create and start the io_uring runtime with non-default parameters, while abstracting away the underlying io_uring crate.

Implementations§

Source§

impl Builder

Source

pub fn entries(&mut self, sq_entries: u32) -> &mut Self

Sets the number of Submission Queue entries in uring.

The default value is 256. The kernel requires the number of submission queue entries to be a power of two, and that it be less than the number of completion queue entries. This function will adjust the cq_entries value to be at least 2 times sq_entries

Source

pub fn uring_builder(&mut self, b: &Builder) -> &mut Self

Replaces the default io_uring::Builder, which controls the settings for the inner io_uring API.

Refer to the io_uring::Builder documentation for all the supported methods.

Source

pub fn start<F: Future>(&self, future: F) -> F::Output

Starts an io_uring enabled Tokio runtime.

§Examples

Creating a uring driver with only 64 submission queue entries but many more completion queue entries.

use tokio::net::TcpListener;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    tokio_uring::builder()
        .entries(64)
        .uring_builder(tokio_uring::uring_builder()
            .setup_cqsize(1024)
            )
        .start(async {
            let listener = TcpListener::bind("127.0.0.1:8080").await?;

            loop {
                let (socket, _) = listener.accept().await?;
                // process socket
            }
        }
    )
}

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.