Expand description
§Product OS : Async Executor
Product OS : Async Executor provides a set of tools to handle async execution generically so that the desired async library (e.g. tokio, smol, async-std) can be chosen at compile time.
§Features
- Generic Executor Traits: Define common interfaces for working with different async runtimes
- Runtime Support: Out-of-the-box support for Tokio, Smol, and Async-std
- Timer Support: One-time and interval timers that work across runtimes
- Async I/O Traits:
AsyncReadandAsyncWritetraits for cross-runtime I/O - No-std Support: Works in
no_stdenvironments with alloc
§Examples
§Using with Tokio
use product_os_async_executor::{Executor, ExecutorPerform, TokioExecutor};
#[tokio::main]
async fn main() {
// Create an executor context
let executor = TokioExecutor::context().await.unwrap();
// Spawn a task
let result = TokioExecutor::spawn_in_context(async {
42
}).await;
assert!(result.is_ok());
}§Using Timers
use product_os_async_executor::{Timer, TokioExecutor};
#[tokio::main]
async fn main() {
let mut timer = TokioExecutor::interval(100).await;
let _ = timer.tick().await; // Waits ~100ms
}§Feature Flags
exec_tokio: Enable Tokio executor supportexec_smol: Enable Smol executor supportexec_async_std: Enable Async-std executor support (deprecated)exec_embassy: Enable Embassy executor support (embedded)moment: Enable time abstraction utilitieshyper_executor: Enable Hyper executor integration
Re-exports§
pub use read_write::IoSlice;
Modules§
- chrono_
compat Deprecated - Deprecated blanket re-export of the chrono crate.
- moment
- Time abstraction utilities for testable time operations.
- read_
write - Async read/write traits for cross-runtime I/O operations.
- sleep
- Sleep trait for cross-runtime sleeping.
Structs§
- Date
Time - ISO 8601 combined date and time with time zone.
- Naive
Date - ISO 8601 calendar date without timezone. Allows for every proleptic Gregorian date from Jan 1, 262145 BCE to Dec 31, 262143 CE. Also supports the conversion from ISO 8601 ordinal and week date.
- Naive
Date Time - ISO 8601 combined date and time without timezone.
- Naive
Time - ISO 8601 time without timezone. Allows for the nanosecond precision and optional leap second representation.
- Spawn
Error - Error type for spawn failures.
- Utc
- The UTC time zone. This is the most efficient time zone when you don’t need the local time. It is also used as an offset (which is also a dummy type).
Traits§
- Executor
- Trait for managing executor contexts across different async runtimes.
- Executor
Perform - Trait for spawning and managing async tasks.
- Task
- Trait representing an async task that can be awaited.
- Time
Zone - The time zone.
- Timer
- Trait for timer functionality across async runtimes.
Type Aliases§
- BoxError
- Type alias for boxed error types that are Send + Sync.
- Chrono
Duration - Alias of
TimeDelta.