pub struct Task<T> { /* private fields */ }Expand description
A set of concurrent actions to be performed by the iced runtime.
A Task may produce a bunch of values of type T.
Implementations§
Source§impl<T> Task<T>
impl<T> Task<T>
Sourcepub fn done(value: T) -> Selfwhere
T: MaybeSend + 'static,
pub fn done(value: T) -> Selfwhere
T: MaybeSend + 'static,
Creates a new Task that instantly produces the given value.
Sourcepub fn perform<A>(
future: impl Future<Output = A> + MaybeSend + 'static,
f: impl FnOnce(A) -> T + MaybeSend + 'static,
) -> Self
pub fn perform<A>( future: impl Future<Output = A> + MaybeSend + 'static, f: impl FnOnce(A) -> T + MaybeSend + 'static, ) -> Self
Sourcepub fn run<A>(
stream: impl Stream<Item = A> + MaybeSend + 'static,
f: impl Fn(A) -> T + MaybeSend + 'static,
) -> Selfwhere
T: 'static,
pub fn run<A>(
stream: impl Stream<Item = A> + MaybeSend + 'static,
f: impl Fn(A) -> T + MaybeSend + 'static,
) -> Selfwhere
T: 'static,
Sourcepub fn batch(tasks: impl IntoIterator<Item = Self>) -> Selfwhere
T: 'static,
pub fn batch(tasks: impl IntoIterator<Item = Self>) -> Selfwhere
T: 'static,
Combines the given tasks and produces a single Task that will run all of them
in parallel.
Sourcepub fn map<O>(self, f: impl FnMut(T) -> O + MaybeSend + 'static) -> Task<O>
pub fn map<O>(self, f: impl FnMut(T) -> O + MaybeSend + 'static) -> Task<O>
Maps the output of a Task with the given closure.
Sourcepub fn chain(self, task: Self) -> Selfwhere
T: 'static,
pub fn chain(self, task: Self) -> Selfwhere
T: 'static,
Chains a new Task to be performed once the current one finishes completely.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Task<T>
impl<T> !RefUnwindSafe for Task<T>
impl<T> Send for Task<T>
impl<T> !Sync for Task<T>
impl<T> Unpin for Task<T>
impl<T> !UnwindSafe for Task<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more