diff options
author | 2020-01-19 10:17:08 +0100 | |
---|---|---|
committer | 2020-01-19 10:17:44 +0100 | |
commit | b5b17ed4d800c03beb3ad535d1069a7784e8dc1d (patch) | |
tree | b9e6477bd11bd6784f8ee61e818b5f5ff1a44318 /core | |
parent | d50ff9b5d97d9c3d6c6c70a9b4efe764b6126c86 (diff) | |
download | iced-b5b17ed4d800c03beb3ad535d1069a7784e8dc1d.tar.gz iced-b5b17ed4d800c03beb3ad535d1069a7784e8dc1d.tar.bz2 iced-b5b17ed4d800c03beb3ad535d1069a7784e8dc1d.zip |
Create `iced_futures` and wire everything up
Diffstat (limited to '')
-rw-r--r-- | core/Cargo.toml | 10 | ||||
-rw-r--r-- | core/src/lib.rs | 18 | ||||
-rw-r--r-- | core/src/runtime/executor.rs | 11 | ||||
-rw-r--r-- | futures/src/command.rs (renamed from core/src/command.rs) | 0 | ||||
-rw-r--r-- | futures/src/runtime.rs (renamed from core/src/runtime.rs) | 13 | ||||
-rw-r--r-- | futures/src/subscription.rs (renamed from core/src/subscription.rs) | 0 | ||||
-rw-r--r-- | futures/src/subscription/tracker.rs (renamed from core/src/subscription/tracker.rs) | 0 |
7 files changed, 9 insertions, 43 deletions
diff --git a/core/Cargo.toml b/core/Cargo.toml index 5e1a5532..22bc7ceb 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -7,14 +7,4 @@ description = "The essential concepts of Iced" license = "MIT" repository = "https://github.com/hecrj/iced" -[features] -# Exposes a future-based `Command` type -command = ["futures"] -# Exposes a future-based `Subscription` type -subscription = ["futures", "log"] -# Exposes a `runtime` module meant to abstract over different future executors -runtime = ["command", "subscription"] - [dependencies] -futures = { version = "0.3", optional = true } -log = { version = "0.4", optional = true } diff --git a/core/src/lib.rs b/core/src/lib.rs index 760acefe..bec307ad 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -32,21 +32,3 @@ pub use length::Length; pub use point::Point; pub use rectangle::Rectangle; pub use vector::Vector; - -#[cfg(feature = "command")] -mod command; - -#[cfg(feature = "command")] -pub use command::Command; - -#[cfg(feature = "subscription")] -pub mod subscription; - -#[cfg(feature = "subscription")] -pub use subscription::Subscription; - -#[cfg(feature = "runtime")] -mod runtime; - -#[cfg(feature = "runtime")] -pub use runtime::Runtime; diff --git a/core/src/runtime/executor.rs b/core/src/runtime/executor.rs deleted file mode 100644 index d171c6d5..00000000 --- a/core/src/runtime/executor.rs +++ /dev/null @@ -1,11 +0,0 @@ -use futures::Future; - -pub trait Executor { - fn new() -> Self; - - fn spawn(&self, future: impl Future<Output = ()> + Send + 'static); - - fn enter<R>(&self, f: impl FnOnce() -> R) -> R { - f() - } -} diff --git a/core/src/command.rs b/futures/src/command.rs index e7885fb8..e7885fb8 100644 --- a/core/src/command.rs +++ b/futures/src/command.rs diff --git a/core/src/runtime.rs b/futures/src/runtime.rs index 31234d11..bc1ad8ac 100644 --- a/core/src/runtime.rs +++ b/futures/src/runtime.rs @@ -1,3 +1,4 @@ +//! Run commands and subscriptions. mod executor; pub use executor::Executor; @@ -10,8 +11,8 @@ use std::marker::PhantomData; #[derive(Debug)] pub struct Runtime<Hasher, Event, Executor, Receiver, Message> { executor: Executor, - subscriptions: subscription::Tracker<Hasher, Event>, receiver: Receiver, + subscriptions: subscription::Tracker<Hasher, Event>, _message: PhantomData<Message>, } @@ -28,15 +29,19 @@ where + 'static, Message: Send + 'static, { - pub fn new(receiver: Receiver) -> Self { + pub fn new(executor: Executor, receiver: Receiver) -> Self { Self { - executor: Executor::new(), - subscriptions: subscription::Tracker::new(), + executor, receiver, + subscriptions: subscription::Tracker::new(), _message: PhantomData, } } + pub fn enter<R>(&self, f: impl FnOnce() -> R) -> R { + self.executor.enter(f) + } + pub fn spawn(&mut self, command: Command<Message>) { use futures::{FutureExt, SinkExt}; diff --git a/core/src/subscription.rs b/futures/src/subscription.rs index 87e51e48..87e51e48 100644 --- a/core/src/subscription.rs +++ b/futures/src/subscription.rs diff --git a/core/src/subscription/tracker.rs b/futures/src/subscription/tracker.rs index a942b619..a942b619 100644 --- a/core/src/subscription/tracker.rs +++ b/futures/src/subscription/tracker.rs |