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 supportmoment: Enable time abstraction utilitieshyper_executor: Enable Hyper executor integration
Modules§
- format
- Formatting (and parsing) utilities for date and time.
- moment
- Time abstraction utilities for testable time operations.
- naive
- Date and time types unconcerned with timezones.
- offset
- The time zone, which calculates offsets from the local time to UTC.
- prelude
- A convenience module appropriate for glob imports (
use chrono::prelude::*;). - read_
write - Async read/write traits for cross-runtime I/O operations.
- round
- Functionality for rounding or truncating a
DateTimeby aTimeDelta. - sleep
- Sleep trait for cross-runtime sleeping. Sleep trait for delaying execution.
Structs§
- Date
Deprecated - ISO 8601 calendar date with time zone.
- Date
Time - ISO 8601 combined date and time with time zone.
- Days
- A duration in calendar days.
- Fixed
Offset - The time zone with fixed offset, from UTC-23:59:59 to UTC+23:59:59.
- IoSlice
- A
#![no_std]-friendly wrapper over the [std::io::IoSliceMut]. - IsoWeek
- ISO 8601 week.
- Local
- The local timescale.
- Months
- A duration in calendar months
- 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.
- Naive
Week - A week represented by a
NaiveDateand aWeekdaywhich is the first day of the week. - OutOf
Range - Out of range error type used in various converting APIs
- OutOf
Range Error - Represents error when converting
TimeDeltato/from a standard library implementation - Parse
Error - An error from the
parsefunction. - Parse
Month Error - An error resulting from reading
<Month>value withFromStr. - Parse
Weekday Error - An error resulting from reading
Weekdayvalue withFromStr. - Time
Delta - Time duration with nanosecond precision.
- 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).
- Weekday
Set - A collection of
Weekdays stored as a single byte.
Enums§
- Local
Result - Old name of
MappedLocalTime. See that type for more documentation. - Month
- The month of the year.
- Rounding
Error - An error from rounding by
TimeDelta - Seconds
Format - Specific formatting options for seconds. This may be extended in the future, so exhaustive matching in external code is not recommended.
- Weekday
- The day of week.
Constants§
- MAX_
DATE Deprecated - The maximum possible
Date. - MAX_
DATETIME Deprecated - The maximum possible
DateTime<Utc>. - MIN_
DATE Deprecated - The minimum possible
Date. - MIN_
DATETIME Deprecated - The minimum possible
DateTime<Utc>.
Traits§
- Datelike
- The common set of methods for date component.
- Duration
Round - Extension trait for rounding or truncating a DateTime by a TimeDelta.
- Executor
- Trait for managing executor contexts across different async runtimes.
- Executor
Perform - Trait for spawning and managing async tasks.
- Offset
- The offset from the local time to UTC.
- Subsec
Round - Extension trait for subsecond rounding or truncation to a maximum number of digits. Rounding can be used to decrease the error variance when serializing/persisting to lower precision. Truncation is the default behavior in Chrono display formatting. Either can be used to guarantee equality (e.g. for testing) when round-tripping through a lower precision format.
- Task
- Trait representing an async task that can be awaited.
- Time
Zone - The time zone.
- Timelike
- The common set of methods for time component.
- Timer
- Trait for timer functionality across async runtimes.
Type Aliases§
- BoxError
- Type alias for boxed error types that are Send + Sync.
- Duration
- Alias of
TimeDelta. - Mapped
Local Time - The result of mapping a local time to a concrete instant in a given time zone.
- Parse
Result - Same as
Result<T, ParseError>.