FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    Task

    struct · ferroui-system · v0.5.0

    struct Task<T>
    

    The outcome of an asynchronous operation (Task<TResult>; Task is Task<()>): a shared handle that ends once, with a result, an error or a cancellation.

    Continuations (continue_with) run synchronously when the task ends (TaskContinuationOptions.ExecuteSynchronously); a task is also a Future of its outcome. Tasks belong to the thread that made them, like the observables (docs/porting/reactive.md, section 5.8).

    View source

    Deprecated since 0.5.0. use ferroui_system::task::Shared<Result<T, ObservableError>> (Shared::channel, JoinHandle::shared, Shared::on_finished); Shared::from(task) converts

    Members

    from_result

    fn from_result(result: T) -> Self
    

    A task that has ended with result (Task.FromResult).

    Source

    from_exception

    fn from_exception(error: ObservableError) -> Self
    

    A task that has ended with error (Task.FromException); a cancellation (Canceled, TaskCanceledError) makes it canceled.

    Source

    from_canceled

    fn from_canceled() -> Self
    

    A canceled task (Task.FromCanceled).

    Source

    spawn_local

    fn spawn_local(future: impl Future<Output = Result<T, ObservableError>> + 'static) -> Self
    

    Runs future on the current thread and gives its task (the counterpart of an async method): see spawn_local.

    Source

    id

    fn id(self: &Self) -> u64
    

    The identity of the task (Id).

    Source

    status

    fn status(self: &Self) -> TaskStatus
    

    The state of the task (Status).

    Source

    is_completed

    fn is_completed(self: &Self) -> bool
    

    Whether the task has ended, in any way (IsCompleted).

    Source

    is_completed_successfully

    fn is_completed_successfully(self: &Self) -> bool
    

    Whether the task has ended with a result (IsCompletedSuccessfully).

    Source

    is_faulted

    fn is_faulted(self: &Self) -> bool
    

    Whether the task has ended with an error (IsFaulted).

    Source

    is_canceled

    fn is_canceled(self: &Self) -> bool
    

    Whether the task has been canceled (IsCanceled).

    Source

    exception

    fn exception(self: &Self) -> Option<ObservableError>
    

    The error of a faulted task (Exception, unwrapped from its AggregateException).

    Source

    result

    fn result(self: &Self) -> Result<T, ObservableError>
    where T: Clone
    

    The outcome of an ended task: the result, the error of a faulted task, or a TaskCanceledError (Result, GetAwaiter().GetResult()).

    Panics

    When the task has not ended: upstream blocks, which would deadlock the only thread.

    Source

    continue_with

    fn continue_with(self: &Self, continuation: impl FnOnce(&Task<T>) -> () + 'static) -> Option<ContinuationId>
    

    Runs continuation when the task ends, synchronously on the thread that ends it, or at once when it has ended (ContinueWith with TaskContinuationOptions.ExecuteSynchronously). The id removes a continuation that has not run (remove_continuation, the cancellation token of ContinueWith); None when it ran at once.

    Source

    remove_continuation

    fn remove_continuation(self: &Self, id: ContinuationId) -> bool
    

    Removes a continuation that has not run; false when it has run or was removed.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • IntoFuture
    • ToOwned
    • Clone
    • Debug
    • Future
    • From<Task<T>>
    • From<Receiver<Result<T, Rc<dyn Error>>>>

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.