diff options
Diffstat (limited to '')
-rw-r--r-- | native/src/lib.rs | 10 | ||||
-rw-r--r-- | native/src/runtime.rs | 12 | ||||
-rw-r--r-- | native/src/subscription.rs | 11 | ||||
-rw-r--r-- | native/src/subscription/events.rs | 5 |
4 files changed, 31 insertions, 7 deletions
diff --git a/native/src/lib.rs b/native/src/lib.rs index 340b9ea7..b5856c00 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -51,13 +51,18 @@ mod element; mod event; mod hasher; mod mouse_cursor; +mod runtime; mod size; mod user_interface; pub use iced_core::{ - Align, Background, Color, Command, Font, HorizontalAlignment, Length, - Point, Rectangle, Vector, VerticalAlignment, + Align, Background, Color, Font, HorizontalAlignment, Length, Point, + Rectangle, Vector, VerticalAlignment, }; +pub use iced_futures::{executor, futures, Command}; + +#[doc(no_inline)] +pub use executor::Executor; pub use clipboard::Clipboard; pub use element::Element; @@ -66,6 +71,7 @@ pub use hasher::Hasher; pub use layout::Layout; pub use mouse_cursor::MouseCursor; pub use renderer::Renderer; +pub use runtime::Runtime; pub use size::Size; pub use subscription::Subscription; pub use user_interface::{Cache, UserInterface}; diff --git a/native/src/runtime.rs b/native/src/runtime.rs new file mode 100644 index 00000000..9fa031f4 --- /dev/null +++ b/native/src/runtime.rs @@ -0,0 +1,12 @@ +//! Run commands and subscriptions. +use crate::{Event, Hasher}; + +/// A native runtime with a generic executor and receiver of results. +/// +/// It can be used by shells to easily spawn a [`Command`] or track a +/// [`Subscription`]. +/// +/// [`Command`]: ../struct.Command.html +/// [`Subscription`]: ../struct.Subscription.html +pub type Runtime<Executor, Receiver, Message> = + iced_futures::Runtime<Hasher, Event, Executor, Receiver, Message>; diff --git a/native/src/subscription.rs b/native/src/subscription.rs index db88867a..0d002c6c 100644 --- a/native/src/subscription.rs +++ b/native/src/subscription.rs @@ -1,6 +1,6 @@ //! Listen to external events in your application. use crate::{Event, Hasher}; -use futures::stream::BoxStream; +use iced_futures::futures::stream::BoxStream; /// A request to listen to external events. /// @@ -15,7 +15,7 @@ use futures::stream::BoxStream; /// /// [`Command`]: ../struct.Command.html /// [`Subscription`]: struct.Subscription.html -pub type Subscription<T> = iced_core::Subscription<Hasher, EventStream, T>; +pub type Subscription<T> = iced_futures::Subscription<Hasher, Event, T>; /// A stream of runtime events. /// @@ -24,7 +24,12 @@ pub type Subscription<T> = iced_core::Subscription<Hasher, EventStream, T>; /// [`Subscription`]: type.Subscription.html pub type EventStream = BoxStream<'static, Event>; -pub use iced_core::subscription::Recipe; +/// A native [`Subscription`] tracker. +/// +/// [`Subscription`]: type.Subscription.html +pub type Tracker = iced_futures::subscription::Tracker<Hasher, Event>; + +pub use iced_futures::subscription::Recipe; mod events; diff --git a/native/src/subscription/events.rs b/native/src/subscription/events.rs index b7301828..7d33166e 100644 --- a/native/src/subscription/events.rs +++ b/native/src/subscription/events.rs @@ -2,10 +2,11 @@ use crate::{ subscription::{EventStream, Recipe}, Event, Hasher, }; +use iced_futures::futures::stream::BoxStream; pub struct Events; -impl Recipe<Hasher, EventStream> for Events { +impl Recipe<Hasher, Event> for Events { type Output = Event; fn hash(&self, state: &mut Hasher) { @@ -17,7 +18,7 @@ impl Recipe<Hasher, EventStream> for Events { fn stream( self: Box<Self>, event_stream: EventStream, - ) -> futures::stream::BoxStream<'static, Self::Output> { + ) -> BoxStream<'static, Self::Output> { event_stream } } |