pub struct RunContext {
pub run_id: String,
pub cancellation: CancellationToken,
pub deadline: Option<Instant>,
pub metadata: BTreeMap<String, Value>,
}Expand description
Execution controls and host-owned metadata for one run.
Fields§
§run_id: StringStable correlation id for this run.
cancellation: CancellationTokenCooperative cancellation source for this run.
deadline: Option<Instant>Optional wall-clock deadline for the run.
metadata: BTreeMap<String, Value>Host-owned execution metadata.
Implementations§
Source§impl RunContext
impl RunContext
Sourcepub fn generated() -> RunContext
pub fn generated() -> RunContext
Constructs a context with a generated process-local run id.
Sourcepub fn new(run_id: impl Into<String>) -> RunContext
pub fn new(run_id: impl Into<String>) -> RunContext
Constructs a context with a caller-provided run id.
Sourcepub fn with_cancellation(self, token: CancellationToken) -> RunContext
pub fn with_cancellation(self, token: CancellationToken) -> RunContext
Sets the cooperative cancellation token.
Sourcepub fn with_deadline(self, deadline: Instant) -> RunContext
pub fn with_deadline(self, deadline: Instant) -> RunContext
Sets an absolute wall-clock deadline.
Sourcepub fn with_timeout(self, timeout: Duration) -> RunContext
pub fn with_timeout(self, timeout: Duration) -> RunContext
Sets a deadline relative to now.
Sourcepub fn with_metadata(self, metadata: BTreeMap<String, Value>) -> RunContext
pub fn with_metadata(self, metadata: BTreeMap<String, Value>) -> RunContext
Sets host-owned execution metadata.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Whether cancellation has been requested.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Whether the deadline has elapsed.
Trait Implementations§
Source§impl Clone for RunContext
impl Clone for RunContext
Source§fn clone(&self) -> RunContext
fn clone(&self) -> RunContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RunContext
impl RefUnwindSafe for RunContext
impl Send for RunContext
impl Sync for RunContext
impl Unpin for RunContext
impl UnsafeUnpin for RunContext
impl UnwindSafe for RunContext
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