Crate rsvow

Crate rsvow 

Source
Expand description

§Promise Crate

This crate provides a Rust-like implementation of JavaScript’s Promise mechanism, allowing asynchronous or delayed computations that can either be fulfilled with a value or rejected with an error. It includes methods for chaining callbacks, catching rejections, running final actions, and various combinators (like all or race) to coordinate multiple promises.

The interface is based on JavaScript’s Promise, but adapted to Rust’s ownership model. For more information, see the MDN Web Docs.

§Usage

To use this crate, create promises through Promise::new, Promise::resolve, or Promise::reject, then chain them with [then], [catch], or [finally]. For example:

use rsvow::{Promise, State};

let promise: Promise<i32, ()> = Promise::resolve(42).then(|value| value * 2);
assert_eq!(promise.state(), State::Fulfilled(84));

For more complex cases, combinators like Promise::all and Promise::race coordinate multiple tasks. See individual function docs for details.

Structs§

Promise
A Promise represents the eventual outcome of an asynchronous operation, similar to JavaScript’s Promise. It may be in one of three states:

Enums§

State
Represents the current state of a promise.