Write documentation for iced_futures
This commit is contained in:
parent
03da887339
commit
f14009601e
11 changed files with 131 additions and 20 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue