mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-10-20 16:14:33 -04:00
* First draft on new task system * Removing save to disk from task system * Bunch of concurrency issues * Solving Future impl issue when pausing tasks * Fix cancel and abort * Bunch of fixes on pause, suspend, resume, cancel and abort Also better error handling on task completion for the user * New capabilities to return an output on a task * Introducing a simple way to linear backoff on failed steal * Sample actor where tasks can dispatch more tasks * Rustfmt * Steal test to make sure * Stale deps cleanup * Removing unused utils * Initial lib docs * Docs ok * Memory cleanup on idle --------- Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com>
29 lines
1.2 KiB
Rust
29 lines
1.2 KiB
Rust
use std::{error::Error, fmt};
|
|
|
|
use super::task::TaskId;
|
|
|
|
/// Task system's error type definition, representing when internal errors occurs.
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum SystemError {
|
|
#[error("task not found <task_id='{0}'>")]
|
|
TaskNotFound(TaskId),
|
|
#[error("task aborted <task_id='{0}'>")]
|
|
TaskAborted(TaskId),
|
|
#[error("task join error <task_id='{0}'>")]
|
|
TaskJoin(TaskId),
|
|
#[error("forced abortion for task <task_id='{0}'> timed out")]
|
|
TaskForcedAbortTimeout(TaskId),
|
|
}
|
|
|
|
/// Trait for errors that can be returned by tasks, we use this trait as a bound for the task system generic
|
|
/// error type.
|
|
///
|
|
///With this trait, we can have a unified error type through all the tasks in the system.
|
|
pub trait RunError: Error + fmt::Debug + Send + Sync + 'static {}
|
|
|
|
/// We provide a blanket implementation for all types that also implements
|
|
/// [`std::error::Error`](https://doc.rust-lang.org/std/error/trait.Error.html) and
|
|
/// [`std::fmt::Debug`](https://doc.rust-lang.org/std/fmt/trait.Debug.html).
|
|
/// So you will not need to implement this trait for your error type, just implement the `Error` and `Debug`
|
|
impl<T: Error + fmt::Debug + Send + Sync + 'static> RunError for T {}
|