ARAL - Async Runtime Aggregation Layer
ARAL is an aggregation layer between your application and the executor for your async stuff. It lets you switch the executors smooth and easy without having to change your applications code.
Runtime
Note: Libraries should not enable any runtime features. You can choose the executor, by using cargo features. There can only be one enabled runtime. Valid features are:
- runtime-tokio
- runtime-async-std
Principle
-
NOT implement async runtime.
Does not implement a concrete asynchronous runtime, only aggregate out-of-the-box asynchronous runtimes.
-
Minimum available.
Try to be as minimal as possible, only add necessary methods, and do not add additional tools (such as channels).
-
Consistent with std.
The asynchronous API style should be as consistent as possible with the synchronous API of std.
Example
For libraries, use aral as a dependency and do not enable any runtime-* features.
# Cargo.toml
[]
= "foo"
= "0.1.0"
= "2021"
[]
= "*"
// lib.rs
use File;
use Result;
pub async
For application, use aral as a dependency and enable one runtime-* features.
# Cargo.toml
[]
= "app"
= "0.1.0"
= "2021"
[]
= { = "*", = ["runtime-tokio"] }
= { = "1.33.0", = ["full"] }
= "0.1.0"
// main.rs
use is_file;
async
Now, you can easily switch between async runtimes by enabling other runtime-* features.
License
Apache-2.0 OR MIT OR MulanPSL-2.0