pub struct TaskContext { /* private fields */ }Expand description
Read-only task identity/configuration 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 configuration(&self) -> &TaskConfig
pub fn configuration(&self) -> &TaskConfig
Borrows the configuration from which this task was generated.
Sourcepub fn value(&self, key: &str) -> Option<&Value>
pub fn value(&self, key: &str) -> Option<&Value>
Borrows one fixed, swept, or explicit task parameter.
Sourcepub fn decode_value<T>(&self, key: &str) -> Result<T, RuntimeError>where
T: DeserializeOwned,
pub fn decode_value<T>(&self, key: &str) -> Result<T, RuntimeError>where
T: DeserializeOwned,
Decodes one required task parameter.
Sourcepub fn progress_handle(&self) -> Option<&TaskProgress>
pub fn progress_handle(&self) -> Option<&TaskProgress>
Borrows iterative progress for a progress task.
Sourcepub fn set_target_iteration(&self, target: u64) -> Result<(), RuntimeError>
pub fn set_target_iteration(&self, target: u64) -> Result<(), RuntimeError>
Sets or replaces the target iteration of a progress task.
Sourcepub fn set_iteration(&self, iteration: u64) -> Result<(), RuntimeError>
pub fn set_iteration(&self, iteration: u64) -> Result<(), RuntimeError>
Synchronizes a progress task to the authoritative scientific iteration.
Sourcepub fn should_continue(&self, iteration: u64) -> Result<bool, RuntimeError>
pub fn should_continue(&self, iteration: u64) -> Result<bool, RuntimeError>
Synchronizes iteration and reports whether work should continue.
Sourcepub fn activity_handle(&self) -> Option<&ActivityTask>
pub fn activity_handle(&self) -> Option<&ActivityTask>
Borrows lifecycle-only reporting for an activity task.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Reports whether the runtime 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.