Struct tokio_uring::Builder

source ·
pub struct Builder { /* private fields */ }
Expand description

Builder API to allow starting the runtime and creating the io_uring driver with non-default parameters.

Implementations§

source§

impl Builder

source

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

Set number of submission queue entries in uring.

The kernel will ensure it uses a power of two and will round this up if necessary. The kernel requires the number of completion queue entries to be larger than the submission queue entries so generally will double the sq entries count.

The caller can specify even a larger cq entries count by using the uring_builder as shown in the start example below.

source

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

Replace the default io_uring Builder. This allows the caller to craft the io_uring Builder using the io_uring crate’s Builder API.

Refer to the Builder start method for an example. Refer to the io_uring::builder documentation for all the supported methods.

source

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

Start 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.