summaryrefslogtreecommitdiffstats
path: root/runtime/src/command
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2023-11-29 14:26:44 +0100
committerLibravatar GitHub <noreply@github.com>2023-11-29 14:26:44 +0100
commit7f8b17604a31e00becc43130ec516c1a53552c88 (patch)
treeb7cbc5ba003d61416d7959a6a704839b53822660 /runtime/src/command
parent7e7d65a23d864e4662c43028a41244ca30cac540 (diff)
parenta761448858521d11dc646e2ef5217e9e06628932 (diff)
downloadiced-7f8b17604a31e00becc43130ec516c1a53552c88.tar.gz
iced-7f8b17604a31e00becc43130ec516c1a53552c88.tar.bz2
iced-7f8b17604a31e00becc43130ec516c1a53552c88.zip
Merge pull request #2150 from iced-rs/feature/command-run
`Stream` support for `Command`
Diffstat (limited to 'runtime/src/command')
-rw-r--r--runtime/src/command/action.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/runtime/src/command/action.rs b/runtime/src/command/action.rs
index 6c74f0ef..6551e233 100644
--- a/runtime/src/command/action.rs
+++ b/runtime/src/command/action.rs
@@ -18,6 +18,11 @@ pub enum Action<T> {
/// [`Future`]: iced_futures::BoxFuture
Future(iced_futures::BoxFuture<T>),
+ /// Run a [`Stream`] to completion.
+ ///
+ /// [`Stream`]: iced_futures::BoxStream
+ Stream(iced_futures::BoxStream<T>),
+
/// Run a clipboard action.
Clipboard(clipboard::Action<T>),
@@ -52,10 +57,11 @@ impl<T> Action<T> {
A: 'static,
T: 'static,
{
- use iced_futures::futures::FutureExt;
+ use iced_futures::futures::{FutureExt, StreamExt};
match self {
Self::Future(future) => Action::Future(Box::pin(future.map(f))),
+ Self::Stream(stream) => Action::Stream(Box::pin(stream.map(f))),
Self::Clipboard(action) => Action::Clipboard(action.map(f)),
Self::Window(window) => Action::Window(window.map(f)),
Self::System(system) => Action::System(system.map(f)),
@@ -74,6 +80,7 @@ impl<T> fmt::Debug for Action<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Future(_) => write!(f, "Action::Future"),
+ Self::Stream(_) => write!(f, "Action::Stream"),
Self::Clipboard(action) => {
write!(f, "Action::Clipboard({action:?})")
}