Crate agnostic_lite

Source
Expand description

Agnostic-Lite

agnostic-lite is an agnostic abstraction layer for any async runtime.

In order to make it trivial for others to build implementations of any async runtime, this crate provides an abstraction layer implementation.

In addition, this crate is not only no_std, but also alloc-free. This means that it can be used in environments where alloc is not available, such as embedded systems. It also has no unsafe code.

github LoC Build codecov

docs.rs crates.io crates.io license

§Introduction

agnostic-lite is an agnostic abstraction layer for any async runtime.

In order to make it trivial for others to build implementations of any async runtime, this crate provides an abstraction layer implementation.

In addition, this crate is not only no_std, but also alloc-free. This means that it can be used in environments where alloc is not available, such as embedded systems. It also has no unsafe code.

agnostic-lite splits the big Runtime trait in agnostic in multiple small traits:

  • AsyncSpawner: trait for spawning tasks
  • AsyncLocalSpawner: trait for spawning local tasks
  • AsyncSleep: trait for sleep functionality
  • AsyncInterval: trait for interval functionality
  • AsyncTimeout: trait for timeout functionality

Builtin supports runtimes:

  • tokio
  • async-std
  • smol
  • wasm-bindgen-futures

§Installation

[dependencies]
agnostic-lite = "0.5"
§License

agnostic-lite is under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE, LICENSE-MIT for details.

Copyright (c) 2025 Al Liu.

Modules§

async_ioasync-io
Time related traits concrete implementations for runtime based on async-io, e.g. async-std, smol.
async_stdasync-std
Concrete runtime implementations based on async-std runtime.
smolsmol
Concrete runtime implementations based on smol runtime.
teststest or test
Unit test for the RuntimeLite
timetime
Time related traits
tokiotokio
Concrete runtime implementations based on tokio runtime.
wasmwasm
Concrete runtime implementations based on wasm-bindgen-futures.

Macros§

cfg_async_std
Macro to conditionally compile items for async-std feature
cfg_linux
Macro to conditionally compile items for linux system
cfg_smol
Macro to conditionally compile items for smol feature
cfg_tokio
Macro to conditionally compile items for tokio feature
cfg_unix
Macro to conditionally compile items for unix system
cfg_windows
Macro to conditionally compile items for windows system

Enums§

AfterHandleErrortime
Error of AfterHandle’s output

Traits§

AfterHandletime
The handle returned by the AsyncAfterSpawner when a after future is spawned.
AsyncAfterSpawnertime
A spawner trait for spawning futures. Go’s time.AfterFunc equivalent.
AsyncBlockingSpawner
A spawner trait for spawning blocking.
AsyncLocalSpawner
A spawner trait for spawning futures.
AsyncSpawner
A spawner trait for spawning futures.
JoinHandle
Joinhanlde trait
LocalJoinHandle
Joinhanlde trait
RuntimeLite
Runtime trait
Yielder
Yielder hints the runtime to execution back