# `future_form` [![crates.io](https://img.shields.io/crates/v/future_form.svg)](https://crates.io/crates/future_form) [![CI](https://ci.hel.subduction.keyhive.org/api/badges/2/status.svg)](https://ci.hel.subduction.keyhive.org/repos/2) [![docs.rs](https://img.shields.io/docsrs/future_form)](https://docs.rs/future_form) [![License](https://img.shields.io/crates/l/future_form.svg)](https://codeberg.org/expede/future_form) > "This isn't even my ~~final~~ _future_ form!" Abstractions over `Send` and `!Send` futures in Rust. ## The Problem Async Rust has a fragmentation problem: some runtimes require `Send` futures (like `tokio`), while others work with `!Send` futures (like Wasm). This forces library authors to either duplicate their async trait implementations or exclude legitimate use cases. ## The Solution `future_form` lets you write async code once and support both `Send` and `!Send` futures: ```rust use future_form::{FutureForm, Sendable, Local, future_form}; use std::marker::PhantomData; trait Counter { fn next(&self) -> K::Future<'_, u32>; } struct Memory { val: u32, _marker: PhantomData, } // Generates impl for both Sendable and Local #[future_form(Sendable, Local)] impl Counter for Memory { fn next(&self) -> K::Future<'_, u32> { let val = self.val; K::from_future(async move { val + 1 }) } } ``` ## Packages | Crate | Description | |----------------------------------------------|-----------------------------------------------------------| | [`future_form`](./future_form) | Core traits and types (`FutureForm`, `Sendable`, `Local`) | | [`future_form_ffi`](./future_form_ffi) | FFI support: host-driven polling, effect slots, handles | | [`future_form_macros`](./future_form_macros) | The `#[future_form]` attribute macro | See the [`future_form` README](./future_form/README.md) for full documentation, usage patterns, and comparisons with `async-trait` and `trait-variant`. ## Examples | Example | Description | |---------|-------------| | [`counter_simple`](./future_form_ffi/examples/counter_simple/) | Introductory: basic counter, Go/Java/Python hosts | | [`counter_effects`](./future_form_ffi/examples/counter_effects/) | Introductory: sans-IO effect protocol, host-fulfilled timestamps + logging | | [`key_value_store`](./future_form_ffi/examples/key_value_store/) | Intermediate: per-future `Arc`, concurrent operations, multi-step futures | ## Design Architecture decisions and rationale are documented in [`design/`](./design/). ## License Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or [MIT license](LICENSE-MIT) at your option.