pub struct TaskValue(/* private fields */);Expand description
A task as a value that can be stored in a property and streamed by a
binding with the ^ operator: the handle to the eventual outcome of an
asynchronous operation, which is an untyped result or an error. It has
identity equality.
The outcome is produced by a TaskValueSource, by a future running on
the dispatcher (TaskValue::run) or is known up front
(TaskValue::from_result, TaskValue::from_exception).
Implementations§
Source§impl TaskValue
impl TaskValue
Sourcepub fn from_result<T: PropertyValue>(value: T) -> Self
pub fn from_result<T: PropertyValue>(value: T) -> Self
A task that has completed with value.
Sourcepub fn from_untyped_result(value: Option<BoxedValue>) -> Self
pub fn from_untyped_result(value: Option<BoxedValue>) -> Self
A task that has completed with an untyped value: null, a boxed value or a shared model object.
Sourcepub fn from_exception(error: BindingError) -> Self
pub fn from_exception(error: BindingError) -> Self
A task that has failed with error.
Sourcepub fn run<F>(future: F) -> Self
pub fn run<F>(future: F) -> Self
Runs future on the dispatcher of the calling thread and returns the
task for its outcome. A future that is dropped before it completes
(the dispatcher shut down, the future panicked) leaves the task
running forever.
Sourcepub fn is_completed(&self) -> bool
pub fn is_completed(&self) -> bool
Whether the task has finished: completed or failed.
Sourcepub fn is_completed_successfully(&self) -> bool
pub fn is_completed_successfully(&self) -> bool
Whether the task ran to completion.
Sourcepub fn is_faulted(&self) -> bool
pub fn is_faulted(&self) -> bool
Whether the task failed.
Sourcepub fn result(&self) -> Option<Result<Option<BoxedValue>, BindingError>>
pub fn result(&self) -> Option<Result<Option<BoxedValue>, BindingError>>
The outcome of the task, if it has finished.
Sourcepub fn continue_with(&self, continuation: impl FnOnce() + 'static)
pub fn continue_with(&self, continuation: impl FnOnce() + 'static)
Runs continuation when the task finishes; right away if it has
finished already. The continuation runs where the task is completed:
a caller that needs it on the dispatcher posts from it.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TaskValue
impl !Send for TaskValue
impl !Sync for TaskValue
impl !UnwindSafe for TaskValue
impl Freeze for TaskValue
impl Unpin for TaskValue
impl UnsafeUnpin for TaskValue
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
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
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more