Trait rdkafka::util::AsyncRuntime[][src]

pub trait AsyncRuntime: Send + Sync + 'static {
    type Delay: Future<Output = ()> + Send;
    fn spawn<T>(task: T)
    where
        T: Future<Output = ()> + Send + 'static
;
fn delay_for(duration: Duration) -> Self::Delay; }

An abstraction over asynchronous runtimes.

There are several asynchronous runtimes available for Rust. By default rust-rdkafka uses Tokio, via the TokioRuntime, but it has pluggable support for any runtime that can satisfy this trait.

For an example of using the smol runtime with rust-rdkafka, see the smol_runtime example.

Associated Types

type Delay: Future<Output = ()> + Send[src]

The type of the future returned by delay_for.

Loading content...

Required methods

fn spawn<T>(task: T) where
    T: Future<Output = ()> + Send + 'static, 
[src]

Spawns an asynchronous task.

The task should be be polled to completion, unless the runtime exits first. With some runtimes this requires an explicit "detach" step.

fn delay_for(duration: Duration) -> Self::Delay[src]

Constructs a future that will resolve after duration has elapsed.

Loading content...

Implementors

impl AsyncRuntime for NaiveRuntime[src]

type Delay = Map<Receiver<()>, fn(_: Result<(), Canceled>)>

impl AsyncRuntime for TokioRuntime[src]

This is supported on crate feature tokio only.

type Delay = Sleep

Loading content...