Skip to main content

TaskTable

Struct TaskTable 

Source
pub struct TaskTable { /* private fields */ }
Expand description

Bounded in-memory task owner; a host drives work by calling checkpoint/update/finish.

Implementations§

Source§

impl TaskTable

Source

pub fn new(capacity: usize) -> Self

Create a table; capacity is clamped to 1..=1024 tasks.

Source

pub fn create( &mut self, action: &str, cancellable: bool, ) -> Result<u64, ActionError>

Allocate a pending task. Completed tasks are retained until explicitly forgotten or, when the table is full, evicted oldest first.

Source

pub fn get(&self, id: u64) -> Result<&Task, ActionError>

Inspect one task, without allowing external callers to mutate its state directly.

Source

pub fn request_cancel(&mut self, id: u64) -> Result<&Task, ActionError>

Request cancellation; completion is reported only when the host acknowledges it.

Source

pub fn checkpoint(&mut self, id: u64) -> Result<bool, ActionError>

Enter a safe interruption point. False means cancelled/finished; do no more work.

Source

pub fn update( &mut self, id: u64, progress: Option<u16>, message: &str, ) -> Result<(), ActionError>

Update progress; host work must still call checkpoint before each interruptible chunk.

Source

pub fn finish( &mut self, id: u64, result: ActionResult, ) -> Result<(), ActionError>

Finish a task. A pending cancellation must first be resolved at a checkpoint.

Source

pub fn fail(&mut self, id: u64, error: ActionError) -> Result<(), ActionError>

Fail a pending/running task with structured diagnostic details.

Source

pub fn forget(&mut self, id: u64) -> Result<(), ActionError>

Remove only a terminal task, retaining monotonic IDs to prevent accidental reuse.

Source

pub fn list(&self, after: u64, limit: usize) -> Result<Value, ActionError>

One ID-ordered page of task metadata.

Trait Implementations§

Source§

impl Default for TaskTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.