summaryrefslogtreecommitdiffstats
path: root/futures/src/executor.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-01-20 09:49:17 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-01-20 09:49:17 +0100
commitf14009601e270e43bdf29b8f4842cf136fbbd8b9 (patch)
treefabfb4d9dced45d28b9fb65be629b40ecda3b402 /futures/src/executor.rs
parent03da887339e3d0590dc84238431b61c211f7cf7e (diff)
downloadiced-f14009601e270e43bdf29b8f4842cf136fbbd8b9.tar.gz
iced-f14009601e270e43bdf29b8f4842cf136fbbd8b9.tar.bz2
iced-f14009601e270e43bdf29b8f4842cf136fbbd8b9.zip
Write documentation for `iced_futures`
Diffstat (limited to 'futures/src/executor.rs')
-rw-r--r--futures/src/executor.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/futures/src/executor.rs b/futures/src/executor.rs
index b2ff043e..c2b9cc72 100644
--- a/futures/src/executor.rs
+++ b/futures/src/executor.rs
@@ -29,13 +29,26 @@ pub use wasm_bindgen::WasmBindgen;
use futures::Future;
+/// A type that can run futures.
pub trait Executor: Sized {
+ /// Creates a new [`Executor`].
+ ///
+ /// [`Executor`]: trait.Executor.html
fn new() -> Result<Self, futures::io::Error>
where
Self: Sized;
+ /// Spawns a future in the [`Executor`].
+ ///
+ /// [`Executor`]: trait.Executor.html
fn spawn(&self, future: impl Future<Output = ()> + Send + 'static);
+ /// Runs the given closure inside the [`Executor`].
+ ///
+ /// Some executors, like `tokio`, require some global state to be in place
+ /// before creating futures. This method can be leveraged to set up this
+ /// global state, call a function, restore the state, and obtain the result
+ /// of the call.
fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
f()
}