pub struct TaskContext { /* private fields */ }Expand description
Read-only task identity plus reporting and cancellation.
The context deliberately has no filesystem, storage, artifact, network, subprocess, or machine-resource operations. The workload owns all such effects directly.
Implementations§
Source§impl TaskContext
impl TaskContext
Sourcepub fn metadata(&self, key: &str) -> Option<&Value>
pub fn metadata(&self, key: &str) -> Option<&Value>
Borrows one application-defined metadata value.
Sourcepub fn decode_metadata<T>(&self, key: &str) -> Result<T, StudyError>where
T: DeserializeOwned,
pub fn decode_metadata<T>(&self, key: &str) -> Result<T, StudyError>where
T: DeserializeOwned,
Decodes one required metadata value.
Sourcepub fn set_target_iteration(&self, target: u64) -> Result<(), StudyError>
pub fn set_target_iteration(&self, target: u64) -> Result<(), StudyError>
Sets or replaces the target iteration of a progress task.
Sourcepub fn set_iteration(&self, iteration: u64) -> Result<(), StudyError>
pub fn set_iteration(&self, iteration: u64) -> Result<(), StudyError>
Synchronizes a progress task to the authoritative scientific iteration.
Sourcepub fn should_continue(&self, iteration: u64) -> Result<bool, StudyError>
pub fn should_continue(&self, iteration: u64) -> Result<bool, StudyError>
Synchronizes iteration and reports whether work should continue.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Reports whether the study requested cooperative cancellation.
Sourcepub fn set_detail(&self, detail: impl Into<String>)
pub fn set_detail(&self, detail: impl Into<String>)
Updates the human-readable task detail.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TaskContext
impl !Sync for TaskContext
impl !UnwindSafe for TaskContext
impl Freeze for TaskContext
impl Send for TaskContext
impl Unpin for TaskContext
impl UnsafeUnpin for TaskContext
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more