🦀🚀 Abstract over
Send and !Send traits
https://crates.io/crates/future_form
- Rust 79.2%
- Python 6.4%
- Java 5.6%
- Go 5.3%
- Nix 1.9%
- Other 1.6%
|
Brooklyn Zelenka
2819d86fac
All checks were successful
ci/woodpecker/push/doc Pipeline was successful
ci/woodpecker/push/audit Pipeline was successful
ci/woodpecker/push/ffi Pipeline was successful
ci/woodpecker/push/spellcheck Pipeline was successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
|
||
|---|---|---|
| .forgejo | Improve docs & tests | |
| .woodpecker | Run CI with .#ci flake | |
| design | Add future_form_ffi | |
| future_form | Disentangle test dependencies | |
| future_form_ffi | Fix license badge | |
| future_form_macros | Add future_form_ffi | |
| .gitignore | Add future_form_ffi | |
| _typos.toml | Improve macro, remove imherent impl ( #6 ) | |
| Cargo.lock | Disentangle test dependencies | |
| Cargo.toml | Add future_form_ffi | |
| CHANGELOG.md | Improve macro, remove imherent impl ( #6 ) | |
| deny.toml | Improve CI | |
| flake.lock | Fix flake | |
| flake.nix | Fix CI | |
| HACKING.md | Rename to future_form and extensivelyrename/refactor ( #2 ) | |
| LICENSE-APACHE | Rename to future_form and extensivelyrename/refactor ( #2 ) | |
| LICENSE-MIT | Rename to future_form and extensivelyrename/refactor ( #2 ) | |
| README.md | Add future_form_ffi | |
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:
usefuture_form::{FutureForm,Sendable,Local,future_form};usestd::marker::PhantomData;traitCounter<K: FutureForm>{fn next(&self)-> K::Future<'_,u32>;}struct Memory<K>{val: u32,_marker: PhantomData<K>,}// Generates impl for both Sendable and Local
#[future_form(Sendable, Local)]impl<K: FutureForm>Counter<K>forMemory<K>{fn next(&self)-> K::Future<'_,u32>{letval=self.val;K::from_future(asyncmove{val+1})}}Packages
| Crate | Description |
|---|---|
future_form |
Core traits and types (FutureForm, Sendable, Local) |
future_form_ffi |
FFI support: host-driven polling, effect slots, handles |
future_form_macros |
The #[future_form] attribute macro |
See the future_form README for full documentation, usage patterns, and comparisons with async-trait and trait-variant.
Examples
| Example | Description |
|---|---|
counter_simple |
Introductory: basic counter, Go/Java/Python hosts |
counter_effects |
Introductory: sans-IO effect protocol, host-fulfilled timestamps + logging |
key_value_store |
Intermediate: per-future Arc<EffectSlot>, concurrent operations, multi-step futures |
Design
Architecture decisions and rationale are documented in design/.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.