diff --git a/Cargo.lock b/Cargo.lock index dbcd5060..efa3db2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2405,6 +2405,7 @@ dependencies = [ "iced_futures", "iced_highlighter", "iced_renderer", + "iced_runtime", "iced_wgpu", "iced_widget", "iced_winit", diff --git a/Cargo.toml b/Cargo.toml index f7318b98..b13c26f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,11 +67,14 @@ auto-detect-theme = ["iced_core/auto-detect-theme"] strict-assertions = ["iced_renderer/strict-assertions"] # Redraws on every runtime event, and not only when a widget requests it unconditional-rendering = ["iced_winit/unconditional-rendering"] +# Enables support for the `sipper` library +sipper = ["iced_runtime/sipper"] [dependencies] iced_core.workspace = true iced_futures.workspace = true iced_renderer.workspace = true +iced_runtime.workspace = true iced_widget.workspace = true iced_winit.features = ["program"] iced_winit.workspace = true diff --git a/examples/download_progress/Cargo.toml b/examples/download_progress/Cargo.toml index 9c52b2bd..56c538fe 100644 --- a/examples/download_progress/Cargo.toml +++ b/examples/download_progress/Cargo.toml @@ -7,7 +7,7 @@ publish = false [dependencies] iced.workspace = true -iced.features = ["tokio"] +iced.features = ["tokio", "sipper"] [dependencies.reqwest] version = "0.12" diff --git a/examples/gallery/Cargo.toml b/examples/gallery/Cargo.toml index 5161f368..3dd5d378 100644 --- a/examples/gallery/Cargo.toml +++ b/examples/gallery/Cargo.toml @@ -7,7 +7,7 @@ publish = false [dependencies] iced.workspace = true -iced.features = ["tokio", "image", "web-colors", "debug"] +iced.features = ["tokio", "sipper", "image", "web-colors", "debug"] reqwest.version = "0.12" reqwest.features = ["json"] diff --git a/examples/websocket/Cargo.toml b/examples/websocket/Cargo.toml index 88ebdae1..c47e3c93 100644 --- a/examples/websocket/Cargo.toml +++ b/examples/websocket/Cargo.toml @@ -7,7 +7,7 @@ publish = false [dependencies] iced.workspace = true -iced.features = ["debug", "tokio"] +iced.features = ["debug", "tokio", "sipper"] warp = "0.3" diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 35704e0f..5fc67b97 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -23,5 +23,7 @@ iced_core.workspace = true iced_futures.workspace = true raw-window-handle.workspace = true -sipper.workspace = true thiserror.workspace = true + +sipper.workspace = true +sipper.optional = true diff --git a/runtime/src/task.rs b/runtime/src/task.rs index fd5970ac..624fc3a7 100644 --- a/runtime/src/task.rs +++ b/runtime/src/task.rs @@ -7,8 +7,10 @@ use crate::futures::futures::future::{self, FutureExt}; use crate::futures::futures::stream::{self, Stream, StreamExt}; use crate::futures::{BoxStream, MaybeSend, boxed_stream}; +use std::convert::Infallible; use std::sync::Arc; +#[cfg(feature = "sipper")] #[doc(no_inline)] pub use sipper::{Never, Sender, Sipper, Straw, sipper, stream}; @@ -60,6 +62,7 @@ impl Task { /// Creates a [`Task`] that runs the given [`Sipper`] to completion, mapping /// progress with the first closure and the output with the second one. + #[cfg(feature = "sipper")] pub fn sip( sipper: S, on_progress: impl FnMut(S::Progress) -> T + MaybeSend + 'static, @@ -391,7 +394,7 @@ where } /// Creates a new [`Task`] that executes the given [`Action`] and produces no output. -pub fn effect(action: impl Into>) -> Task { +pub fn effect(action: impl Into>) -> Task { let action = action.into(); Task(Some(boxed_stream(stream::once(async move { diff --git a/src/lib.rs b/src/lib.rs index 2d4b6b69..ebb80282 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -531,9 +531,10 @@ pub use alignment::Vertical::{Bottom, Top}; pub mod task { //! Create runtime tasks. - pub use crate::runtime::task::{ - Handle, Never, Sipper, Straw, Task, sipper, stream, - }; + pub use crate::runtime::task::{Handle, Task}; + + #[cfg(feature = "sipper")] + pub use crate::runtime::task::{Never, Sipper, Straw, sipper, stream}; } pub mod clipboard {