futures_scopes/lib.rs
1//! An extension to [futures-rs](https://github.com/rust-lang/futures-rs) that offers scopes.
2//! Scopes can be used to spawn non-static futures that can reference variables on the stack
3//! that were created before the scope was created.
4//!
5//! There are currently two different Scope types:
6//! - For spawning local non-send/sync futures, use [`LocalScope`](local::LocalScope).
7//! - For spawning futures on multiple, underlying spawns, use [`RelayScope`](relay::RelayScope).
8//!
9//! # Features
10//!
11//! The following features are available on the crate:
12//!
13//! - `local`: Enables [`LocalScope`](local::LocalScope).
14//! - `relay`: Enables [`RelayScope`](relay::RelayScope).
15//!
16//! By default both features are enabled.
17//! To only use one of the features, disable the default features and enable the feature you want to use.
18//! For example:
19//!
20//! ```toml
21//! [dependencies]
22//! futures-scopes = {version = "...", default-features = false, features = ["local"]}
23//! ```
24
25#![warn(missing_docs)]
26
27/// Provides [`LocalScope`](local::LocalScope), which can spawn non-send/sync futures of non-static lifetime.
28#[cfg(feature = "local")]
29pub mod local;
30
31/// Provides [`RelayScope`](relay::RelayScope), which can spawn send/sync futures of non-static lifetime.
32#[cfg(feature = "relay")]
33pub mod relay;
34
35mod scoped_spawn;
36mod spawn_scope;
37
38pub use scoped_spawn::*;
39pub use spawn_scope::*;