From ec1f34ccea92b049a462664703351fe7e094fb02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 26 Mar 2020 14:53:58 +0100 Subject: [PATCH] Add `BoxFutures` and `BoxStream` to `iced_futures` --- futures/src/lib.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/futures/src/lib.rs b/futures/src/lib.rs index c25c0853..79178931 100644 --- a/futures/src/lib.rs +++ b/futures/src/lib.rs @@ -16,3 +16,31 @@ pub use command::Command; pub use executor::Executor; pub use runtime::Runtime; pub use subscription::Subscription; + +/// A boxed static future. +/// +/// - On native platforms, it needs a `Send` requirement. +/// - On the Web platform, it does not need a `Send` requirement. +#[cfg(not(target_arch = "wasm32"))] +pub type BoxFuture = futures::future::BoxFuture<'static, T>; + +/// A boxed static future. +/// +/// - On native platforms, it needs a `Send` requirement. +/// - On the Web platform, it does not need a `Send` requirement. +#[cfg(target_arch = "wasm32")] +pub type BoxFuture = futures::future::LocalBoxFuture<'static, T>; + +/// A boxed static stream. +/// +/// - On native platforms, it needs a `Send` requirement. +/// - On the Web platform, it does not need a `Send` requirement. +#[cfg(not(target_arch = "wasm32"))] +pub type BoxStream = futures::stream::BoxStream<'static, T>; + +/// A boxed static stream. +/// +/// - On native platforms, it needs a `Send` requirement. +/// - On the Web platform, it does not need a `Send` requirement. +#[cfg(target_arch = "wasm32")] +pub type BoxStream = futures::stream::LocalBoxStream<'static, T>;