| Crates.io | promisery |
| lib.rs | promisery |
| version | 2.0.1 |
| created_at | 2025-07-03 12:11:27.456977+00 |
| updated_at | 2025-07-04 11:52:28.03913+00 |
| description | A JavaScript-inspired, ergonomic, and composable Promise type for Rust, supporting background work, chaining, and error handling with Result. |
| homepage | |
| repository | https://github.com/Orkking2/rust-promises |
| max_upload_size | |
| id | 1736176 |
| size | 33,924 |
A JavaScript-inspired, ergonomic, and composable Promise type for Rust, supporting background work, chaining, and error handling with Result.
.then, .map, and .map_errPromise::all, Promise::racewait_timeout] or [wait_deadline]wait] (safe, double Result) and [wait_nopanic] (unsafe, panics on background panic)Add to your Cargo.toml:
promisery = "2.0"
use promisery::Promise;
let p = Promise::<_, ()>::new(|| Ok(2))
.then(|res| res.map(|v| v * 10))
.then(|res| res.map(|v| v + 5));
assert_eq!(p.wait(), Ok(Ok(25)));
.then for full control over result and error.map for value transformation.map_err for error transformationPromise::all waits for all promises (returns Result<Result<Vec<T>, E>, PromisePanic>)Promise::race resolves/rejects with the first to finish (returns Result<Result<T, E>, PromisePanic>).wait() — safe, never panics, returns a double Result.wait_nopanic() — unsafe, panics if the background task panicked.wait_timeout(duration) — wait with a timeout.wait_deadline(instant) — wait until a deadlinePromisePanicResult-based error handlingMIT OR Apache-2.0
See docs.rs/promisery for full documentation, API details, and more examples, including usage of wait_nopanic, wait_timeout, and wait_deadline.