pub struct RunContext {
pub run_id: String,
pub cancellation: CancellationToken,
pub deadline: Option<Instant>,
pub metadata: RunMetadata,
}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: RunMetadataHost-owned execution metadata.
Implementations§
Source§impl RunContext
impl RunContext
Sourcepub fn new(run_id: impl Into<String>) -> Self
pub fn new(run_id: impl Into<String>) -> Self
Constructs a context with a caller-provided run id.
Sourcepub fn with_cancellation(self, token: CancellationToken) -> Self
pub fn with_cancellation(self, token: CancellationToken) -> Self
Sets the cooperative cancellation token.
Sourcepub fn with_deadline(self, deadline: Instant) -> Self
pub fn with_deadline(self, deadline: Instant) -> Self
Sets an absolute wall-clock deadline.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets a deadline relative to now.
Sourcepub fn with_metadata(self, metadata: RunMetadata) -> Self
pub fn with_metadata(self, metadata: RunMetadata) -> Self
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