Skip to main content

Task

Struct Task 

Source
pub struct Task {
    pub id: TaskId,
    pub name: Option<String>,
    pub priority: TaskPriority,
    pub state: TaskState,
    pub action: RtObject,
    pub dependencies: Vec<TaskId>,
    pub dependents: Vec<TaskId>,
    pub created_at: u64,
    pub completed_at: Option<u64>,
}
Expand description

A task represents a unit of work to be executed.

Fields§

§id: TaskId

Unique task identifier.

§name: Option<String>

Human-readable name (for debugging).

§priority: TaskPriority

Priority.

§state: TaskState

Current state.

§action: RtObject

The closure to execute (represented as an RtObject).

§dependencies: Vec<TaskId>

Dependencies (tasks that must complete before this one).

§dependents: Vec<TaskId>

Tasks that depend on this one (notified on completion).

§created_at: u64

Creation timestamp (nanoseconds).

§completed_at: Option<u64>

Completion timestamp (nanoseconds).

Implementations§

Source§

impl Task

Source

pub fn new(id: TaskId, action: RtObject) -> Self

Create a new task.

Source

pub fn named(id: TaskId, name: String, action: RtObject) -> Self

Create a named task.

Source

pub fn with_priority(self, priority: TaskPriority) -> Self

Set the priority.

Source

pub fn depends_on(self, dep: TaskId) -> Self

Add a dependency.

Source

pub fn dependencies_satisfied(&self, completed: &[TaskId]) -> bool

Check if all dependencies are satisfied.

Source

pub fn complete(&mut self, result: RtObject)

Mark as completed.

Source

pub fn fail(&mut self, error: String)

Mark as failed.

Source

pub fn cancel(&mut self)

Mark as cancelled.

Source

pub fn result(&self) -> Option<&RtObject>

Get the result if completed.

Source

pub fn error(&self) -> Option<&str>

Get the error if failed.

Trait Implementations§

Source§

impl Clone for Task

Source§

fn clone(&self) -> Task

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Task

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Task

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Task

§

impl RefUnwindSafe for Task

§

impl Send for Task

§

impl Sync for Task

§

impl Unpin for Task

§

impl UnsafeUnpin for Task

§

impl UnwindSafe for Task

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.