1use futures::stream::{Stream, StreamExt};
7use std::future::Future;
8
9pub fn batch<X: Send + 'static + Into<Y>, Y: Send + 'static>(
11 tasks: impl IntoIterator<Item = iced::Task<X>>,
12) -> iced::Task<Y> {
13 iced::Task::batch(tasks).map(Into::into)
14}
15
16pub fn future<X: Into<Y>, Y: 'static>(
18 future: impl Future<Output = X> + Send + 'static,
19) -> iced::Task<Y> {
20 iced::Task::future(async move { future.await.into() })
21}
22
23pub fn message<X: Send + 'static + Into<Y>, Y: 'static>(message: X) -> iced::Task<Y> {
25 future(async move { message.into() })
26}
27
28pub fn stream<X: Into<Y> + 'static, Y: 'static>(
30 stream: impl Stream<Item = X> + Send + 'static,
31) -> iced::Task<Y> {
32 iced::Task::stream(stream.map(Into::into))
33}