summaryrefslogtreecommitdiffstats
path: root/futures/src/runtime.rs
diff options
context:
space:
mode:
Diffstat (limited to 'futures/src/runtime.rs')
-rw-r--r--futures/src/runtime.rs49
1 files changed, 46 insertions, 3 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`].
///