#async-channel #async-await #async-executor #abstraction-layer #async-std #tokio #run-time

async-compatibility-layer

an abstraction layer for using both async-std and tokio

3 stable releases

1.2.1 Jul 10, 2024
1.2.0 Jun 3, 2024
1.1.0 Apr 2, 2024

#471 in Asynchronous

Download history 631/week @ 2024-08-05 527/week @ 2024-08-12 272/week @ 2024-08-19 1027/week @ 2024-08-26 625/week @ 2024-09-02 613/week @ 2024-09-09 537/week @ 2024-09-16 582/week @ 2024-09-23 489/week @ 2024-09-30 525/week @ 2024-10-07 536/week @ 2024-10-14 677/week @ 2024-10-21 697/week @ 2024-10-28 617/week @ 2024-11-04 471/week @ 2024-11-11 436/week @ 2024-11-18

2,226 downloads per month
Used in 2 crates

MIT license

67KB
1K SLoC

What is this?

This crate exports four things:

  • A compatibility/abstraction layer for writing async-executor agnostic code. We support two async executors: async-std and tokio. Each may be toggled with a configuration flag.
  • A compatibility/abstraction layer for writing async channel agnostic code. We support three async channel implementations: async-std, tokio and flume. Each may be toggled with a configuration flag.
  • A library exporting a bunch of useful async primitives.
  • A tracing configuration layer optionally supporting console and opentelemetry integration.

Example usage

By default the async-std executor and channels are used.

To use tokio:

RUSTFLAGS='--cfg async_executor_impl="tokio" --cfg async_channel_impl="tokio"' cargo build

async_executor_impl may be either tokio or async-std. async_channel_impl may be either tokio, async-std, or flume.

Note that using tokio channels requires tokio to be the runtime.


lib.rs:

Async compatibility layer meant to control abstractions between tokio and async_std with a feature flag toggle while exposing the same interface for general consumption between both

Dependencies

~6–20MB
~279K SLoC