aimdb-executor
Pure async executor trait definitions for AimDB - runtime-agnostic abstractions.
Overview
aimdb-executor provides the trait abstractions that enable AimDB to work across different async runtime environments. This crate has zero dependencies and defines only traits, enabling dependency inversion where the core database depends on abstractions rather than concrete implementations.
Key Features:
- Runtime Agnostic: No concrete runtime dependencies
- Simple Trait Structure: 4 focused traits covering all runtime needs
- Platform Flexible: Works across std and no_std environments
- Zero Dependencies: Pure trait definitions with minimal coupling
Architecture
┌────────────────────────────────────────┐
│ aimdb-executor (traits) │
│ - RuntimeAdapter │
│ - TimeOps │
│ - Logger │
│ - Spawn │
└────────────────────────────────────────┘
△ △
│ │
┌───────┴────┐ ┌────┴──────┐
│ Tokio │ │ Embassy │
│ Adapter │ │ Adapter │
└────────────┘ └───────────┘
Trait Overview
1. RuntimeAdapter
Platform identification and metadata:
Usage: Identify runtime at compile-time (associated function, not method).
2. TimeOps
Time operations for async contexts:
Usage: Generic time operations with platform-specific Instant/Duration types.
3. Logger
Structured logging abstraction:
Usage: Logging that works across tracing (std) and defmt (embedded).
4. Spawn
Task spawning with platform-specific tokens:
Usage: Spawn async tasks with runtime-appropriate tokens (JoinHandle, SpawnToken, etc.).
Quick Start
Implementing an Adapter
use ;
use Future;
;
Error Types
Simple error enum for executor operations:
pub type ExecutorResult<T> = ;
Trait Variants
All traits are directly usable - no trait_variant macros used. All traits require Send + Sync bounds where appropriate.
Usage in AimDB Core
The core database is generic over runtime traits:
Runtime Trait Bundle
A convenience trait that bundles all requirements:
// Auto-implemented for any type with all four traits
Existing Implementations
Two official adapters are available:
Tokio Adapter
[]
= "0.1"
- Standard library environments
- Uses
tokio::time,tokio::task,tracing
Embassy Adapter
[]
= "0.1"
- Embedded no_std environments
- Uses
embassy_time,embassy_executor,defmt
Design Philosophy
- Minimal Surface Area: Only essential operations
- No Concrete Dependencies: Pure trait definitions
- Platform Neutral: Works across std and no_std
- Future Proof: Easy to extend without breaking changes
Features
[]
= [] # Enable standard library support
Testing
# Run tests
# Check no_std compatibility
Documentation
Generate API docs:
Examples
See adapter implementations:
aimdb-tokio-adapter/src/lib.rs- Full Tokio implementationaimdb-embassy-adapter/src/lib.rs- Full Embassy implementation
License
See LICENSE file.