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,
) -> Selfwhere
T: MaybeSend + 'static,
A: MaybeSend + 'static,
pub fn perform<A>(
future: impl Future<Output = A> + MaybeSend + 'static,
f: impl FnOnce(A) -> T + MaybeSend + 'static,
) -> Selfwhere
T: MaybeSend + 'static,
A: MaybeSend + 'static,
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,
Creates a Task
that runs the given [Stream
] to completion and maps each
item with the given closure.
Sourcepub fn sip<S>(
sipper: S,
on_progress: impl FnMut(S::Progress) -> T + MaybeSend + 'static,
on_output: impl FnOnce(<S as Future>::Output) -> T + MaybeSend + 'static,
) -> Selfwhere
S: Core + MaybeSend + 'static,
T: MaybeSend + 'static,
Available on crate feature sipper
only.
pub fn sip<S>(
sipper: S,
on_progress: impl FnMut(S::Progress) -> T + MaybeSend + 'static,
on_output: impl FnOnce(<S as Future>::Output) -> T + MaybeSend + 'static,
) -> Selfwhere
S: Core + MaybeSend + 'static,
T: MaybeSend + 'static,
sipper
only.Creates a Task
that runs the given [Sipper
] to completion, mapping
progress with the first closure and the output with the second one.
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>where
T: MaybeSend + 'static,
O: MaybeSend + 'static,
pub fn map<O>(self, f: impl FnMut(T) -> O + MaybeSend + 'static) -> Task<O>where
T: MaybeSend + 'static,
O: MaybeSend + 'static,
Maps the output of a Task
with the given closure.
Sourcepub fn then<O>(
self,
f: impl FnMut(T) -> Task<O> + MaybeSend + 'static,
) -> Task<O>where
T: MaybeSend + 'static,
O: MaybeSend + 'static,
pub fn then<O>(
self,
f: impl FnMut(T) -> Task<O> + MaybeSend + 'static,
) -> Task<O>where
T: MaybeSend + 'static,
O: MaybeSend + 'static,
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