summaryrefslogtreecommitdiffstats
path: root/futures
diff options
context:
space:
mode:
authorLibravatar Vladyslav Nikonov <mail@pacmancoder.xyz>2021-10-21 22:42:14 +0300
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-01-28 21:37:14 +0700
commitbdca20fc4a3e8f6bd8ffb59de75e6ca0f8a94b6a (patch)
tree8ea0d2ff0a0d780ff763d7491fc67878f549a615 /futures
parentc75ed37148b019358b0297171cf31b2577eeb9ae (diff)
downloadiced-bdca20fc4a3e8f6bd8ffb59de75e6ca0f8a94b6a.tar.gz
iced-bdca20fc4a3e8f6bd8ffb59de75e6ca0f8a94b6a.tar.bz2
iced-bdca20fc4a3e8f6bd8ffb59de75e6ca0f8a94b6a.zip
Experimental wgpu WebGL backend support
- Added missing `draw_cache_align_4x4` call for `brush_glyph` on wasm32 target - Added WebGL support to `integratio_wgpu` example - Fixed test.yml CI workflow - Removed spir-v shader in `integration_wgpu`; Fixed formatting - Removed redundant `BoxStream` typedef
Diffstat (limited to 'futures')
-rw-r--r--futures/src/runtime.rs49
-rw-r--r--futures/src/subscription/tracker.rs52
2 files changed, 92 insertions, 9 deletions
diff --git a/futures/src/runtime.rs b/futures/src/runtime.rs
index 7779e235..96104cd9 100644
--- a/futures/src/runtime.rs
+++ b/futures/src/runtime.rs
@@ -5,6 +5,50 @@ use crate::{subscription, Executor, Subscription};
use futures::{channel::mpsc, Sink};
use std::marker::PhantomData;
+#[cfg(not(target_arch = "wasm32"))]
+mod trait_aliases {
+ use super::*;
+
+ pub trait RuntimeMessage: Send + 'static {}
+
+ impl<T> RuntimeMessage for T where T: Send + 'static {}
+
+ pub trait RuntimeMessageSender<Message: RuntimeMessage>:
+ Sink<Message, Error = mpsc::SendError> + Unpin + Send + Clone + 'static
+ {
+ }
+
+ impl<Message: RuntimeMessage, T> RuntimeMessageSender<Message> for T where
+ T: Sink<Message, Error = mpsc::SendError>
+ + Unpin
+ + Send
+ + Clone
+ + 'static
+ {
+ }
+}
+
+#[cfg(target_arch = "wasm32")]
+mod trait_aliases {
+ use super::*;
+
+ pub trait RuntimeMessage: 'static {}
+
+ impl<T> RuntimeMessage for T where T: 'static {}
+
+ pub trait RuntimeMessageSender<Message: RuntimeMessage>:
+ Sink<Message, Error = mpsc::SendError> + Unpin + Clone + 'static
+ {
+ }
+
+ impl<Message: RuntimeMessage, T> RuntimeMessageSender<Message> for T where
+ T: Sink<Message, Error = mpsc::SendError> + Unpin + Clone + 'static
+ {
+ }
+}
+
+pub use trait_aliases::{RuntimeMessage, RuntimeMessageSender};
+
/// A batteries-included runtime of commands and subscriptions.
///
/// If you have an [`Executor`], a [`Runtime`] can be leveraged to run any
@@ -23,9 +67,8 @@ where
Hasher: std::hash::Hasher + Default,
Event: Send + Clone + 'static,
Executor: self::Executor,
- Sender:
- Sink<Message, Error = mpsc::SendError> + Unpin + Send + Clone + 'static,
- Message: Send + 'static,
+ Sender: RuntimeMessageSender<Message>,
+ Message: RuntimeMessage,
{
/// Creates a new empty [`Runtime`].
///
diff --git a/futures/src/subscription/tracker.rs b/futures/src/subscription/tracker.rs
index 3a8d4a87..01e0c105 100644
--- a/futures/src/subscription/tracker.rs
+++ b/futures/src/subscription/tracker.rs
@@ -3,6 +3,50 @@ use crate::{BoxFuture, Subscription};
use futures::{channel::mpsc, sink::Sink};
use std::{collections::HashMap, marker::PhantomData};
+#[cfg(not(target_arch = "wasm32"))]
+mod trait_aliases {
+ use super::*;
+
+ pub trait TrackerMessage: Send + 'static {}
+
+ impl<T> TrackerMessage for T where T: Send + 'static {}
+
+ pub trait TrackerMessageReceiver<Message: TrackerMessage>:
+ Sink<Message, Error = mpsc::SendError> + Unpin + Send + Clone + 'static
+ {
+ }
+
+ impl<Message: TrackerMessage, T> TrackerMessageReceiver<Message> for T where
+ T: Sink<Message, Error = mpsc::SendError>
+ + Unpin
+ + Send
+ + Clone
+ + 'static
+ {
+ }
+}
+
+#[cfg(target_arch = "wasm32")]
+mod trait_aliases {
+ use super::*;
+
+ pub trait TrackerMessage: 'static {}
+
+ impl<T> TrackerMessage for T where T: 'static {}
+
+ pub trait TrackerMessageReceiver<Message: TrackerMessage>:
+ Sink<Message, Error = mpsc::SendError> + Unpin + Clone + 'static
+ {
+ }
+
+ impl<Message: TrackerMessage, T> TrackerMessageReceiver<Message> for T where
+ T: Sink<Message, Error = mpsc::SendError> + Unpin + Clone + 'static
+ {
+ }
+}
+
+pub use trait_aliases::{TrackerMessage, TrackerMessageReceiver};
+
/// A registry of subscription streams.
///
/// If you have an application that continuously returns a [`Subscription`],
@@ -57,12 +101,8 @@ where
receiver: Receiver,
) -> Vec<BoxFuture<()>>
where
- Message: 'static + Send,
- Receiver: 'static
- + Sink<Message, Error = mpsc::SendError>
- + Unpin
- + Send
- + Clone,
+ Message: TrackerMessage,
+ Receiver: TrackerMessageReceiver<Message>,
{
use futures::{future::FutureExt, stream::StreamExt};