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
impl TaskTable
Sourcepub fn create(
&mut self,
action: &str,
cancellable: bool,
) -> Result<u64, ActionError>
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.
Sourcepub fn get(&self, id: u64) -> Result<&Task, ActionError>
pub fn get(&self, id: u64) -> Result<&Task, ActionError>
Inspect one task, without allowing external callers to mutate its state directly.
Sourcepub fn request_cancel(&mut self, id: u64) -> Result<&Task, ActionError>
pub fn request_cancel(&mut self, id: u64) -> Result<&Task, ActionError>
Request cancellation; completion is reported only when the host acknowledges it.
Sourcepub fn checkpoint(&mut self, id: u64) -> Result<bool, ActionError>
pub fn checkpoint(&mut self, id: u64) -> Result<bool, ActionError>
Enter a safe interruption point. False means cancelled/finished; do no more work.
Sourcepub fn update(
&mut self,
id: u64,
progress: Option<u16>,
message: &str,
) -> Result<(), ActionError>
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.
Sourcepub fn finish(
&mut self,
id: u64,
result: ActionResult,
) -> Result<(), ActionError>
pub fn finish( &mut self, id: u64, result: ActionResult, ) -> Result<(), ActionError>
Finish a task. A pending cancellation must first be resolved at a checkpoint.
Sourcepub fn fail(&mut self, id: u64, error: ActionError) -> Result<(), ActionError>
pub fn fail(&mut self, id: u64, error: ActionError) -> Result<(), ActionError>
Fail a pending/running task with structured diagnostic details.
Trait Implementations§
Auto Trait Implementations§
impl Forget for TaskTable
impl Freeze for TaskTable
impl RefUnwindSafe for TaskTable
impl Send for TaskTable
impl Sync for TaskTable
impl Unpin for TaskTable
impl UnsafeUnpin for TaskTable
impl UnwindSafe for TaskTable
Blanket Implementations§
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
Mutably borrows from an owned value. Read more