executor-core 0.1.0

A flexible task executor abstraction layer for Rust async runtimes
Documentation

executor-core

MIT licensed Crates.io Documentation

A flexible task executor abstraction layer for Rust async runtimes.

Overview

executor-core provides a unified interface for spawning and managing async tasks across different executor backends. Write once, run on any supported async runtime.

Features

  • Runtime agnostic - Works with async-executor, tokio, and custom executors
  • Zero-cost abstractions - Compiles to direct executor calls
  • Panic handling - Graceful error recovery from task panics
  • No-std support - Works in embedded environments

Quick Start

Add to your Cargo.toml:

[dependencies]
executor-core = "0.1"

Basic usage:

use executor_core::spawn;

async fn main() {
    let task = spawn(async {
        println!("Hello from task!");
        42
    });

    let result = task.await;
    println!("Result: {}", result);
}

Error Handling

use executor_core::{spawn, Error};

let task = spawn(async { 42 });

match task.result().await {
    Ok(value) => println!("Success: {}", value),
    Err(Error::Panicked(msg)) => println!("Task panicked: {}", msg),
    Err(Error::Cancelled) => println!("Task was cancelled"),
}

Feature Flags

  • default-async-executor (default) - Use async-executor as global executor
  • default-tokio - Use tokio as global executor
  • async-executor - Enable async-executor backend
  • tokio - Enable tokio backend
  • std - Enable standard library support

License

Licensed under the MIT License.