Make sipper dependency optional

This commit is contained in:
Héctor Ramón Jiménez 2025-04-02 10:58:09 +02:00
parent cf827dd349
commit 9f1beba583
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
8 changed files with 18 additions and 8 deletions

1
Cargo.lock generated
View file

@ -2405,6 +2405,7 @@ dependencies = [
"iced_futures", "iced_futures",
"iced_highlighter", "iced_highlighter",
"iced_renderer", "iced_renderer",
"iced_runtime",
"iced_wgpu", "iced_wgpu",
"iced_widget", "iced_widget",
"iced_winit", "iced_winit",

View file

@ -67,11 +67,14 @@ auto-detect-theme = ["iced_core/auto-detect-theme"]
strict-assertions = ["iced_renderer/strict-assertions"] strict-assertions = ["iced_renderer/strict-assertions"]
# Redraws on every runtime event, and not only when a widget requests it # Redraws on every runtime event, and not only when a widget requests it
unconditional-rendering = ["iced_winit/unconditional-rendering"] unconditional-rendering = ["iced_winit/unconditional-rendering"]
# Enables support for the `sipper` library
sipper = ["iced_runtime/sipper"]
[dependencies] [dependencies]
iced_core.workspace = true iced_core.workspace = true
iced_futures.workspace = true iced_futures.workspace = true
iced_renderer.workspace = true iced_renderer.workspace = true
iced_runtime.workspace = true
iced_widget.workspace = true iced_widget.workspace = true
iced_winit.features = ["program"] iced_winit.features = ["program"]
iced_winit.workspace = true iced_winit.workspace = true

View file

@ -7,7 +7,7 @@ publish = false
[dependencies] [dependencies]
iced.workspace = true iced.workspace = true
iced.features = ["tokio"] iced.features = ["tokio", "sipper"]
[dependencies.reqwest] [dependencies.reqwest]
version = "0.12" version = "0.12"

View file

@ -7,7 +7,7 @@ publish = false
[dependencies] [dependencies]
iced.workspace = true iced.workspace = true
iced.features = ["tokio", "image", "web-colors", "debug"] iced.features = ["tokio", "sipper", "image", "web-colors", "debug"]
reqwest.version = "0.12" reqwest.version = "0.12"
reqwest.features = ["json"] reqwest.features = ["json"]

View file

@ -7,7 +7,7 @@ publish = false
[dependencies] [dependencies]
iced.workspace = true iced.workspace = true
iced.features = ["debug", "tokio"] iced.features = ["debug", "tokio", "sipper"]
warp = "0.3" warp = "0.3"

View file

@ -23,5 +23,7 @@ iced_core.workspace = true
iced_futures.workspace = true iced_futures.workspace = true
raw-window-handle.workspace = true raw-window-handle.workspace = true
sipper.workspace = true
thiserror.workspace = true thiserror.workspace = true
sipper.workspace = true
sipper.optional = true

View file

@ -7,8 +7,10 @@ use crate::futures::futures::future::{self, FutureExt};
use crate::futures::futures::stream::{self, Stream, StreamExt}; use crate::futures::futures::stream::{self, Stream, StreamExt};
use crate::futures::{BoxStream, MaybeSend, boxed_stream}; use crate::futures::{BoxStream, MaybeSend, boxed_stream};
use std::convert::Infallible;
use std::sync::Arc; use std::sync::Arc;
#[cfg(feature = "sipper")]
#[doc(no_inline)] #[doc(no_inline)]
pub use sipper::{Never, Sender, Sipper, Straw, sipper, stream}; pub use sipper::{Never, Sender, Sipper, Straw, sipper, stream};
@ -60,6 +62,7 @@ impl<T> Task<T> {
/// Creates a [`Task`] that runs the given [`Sipper`] to completion, mapping /// Creates a [`Task`] that runs the given [`Sipper`] to completion, mapping
/// progress with the first closure and the output with the second one. /// progress with the first closure and the output with the second one.
#[cfg(feature = "sipper")]
pub fn sip<S>( pub fn sip<S>(
sipper: S, sipper: S,
on_progress: impl FnMut(S::Progress) -> T + MaybeSend + 'static, 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. /// Creates a new [`Task`] that executes the given [`Action`] and produces no output.
pub fn effect<T>(action: impl Into<Action<Never>>) -> Task<T> { pub fn effect<T>(action: impl Into<Action<Infallible>>) -> Task<T> {
let action = action.into(); let action = action.into();
Task(Some(boxed_stream(stream::once(async move { Task(Some(boxed_stream(stream::once(async move {

View file

@ -531,9 +531,10 @@ pub use alignment::Vertical::{Bottom, Top};
pub mod task { pub mod task {
//! Create runtime tasks. //! Create runtime tasks.
pub use crate::runtime::task::{ pub use crate::runtime::task::{Handle, Task};
Handle, Never, Sipper, Straw, Task, sipper, stream,
}; #[cfg(feature = "sipper")]
pub use crate::runtime::task::{Never, Sipper, Straw, sipper, stream};
} }
pub mod clipboard { pub mod clipboard {