pub struct RunContext { /* private fields */ }Expand description
The authority, lifetime, and accounting scope of one run.
Implementations§
Source§impl RunContext
impl RunContext
Sourcepub fn root(budget: BudgetTracker, capabilities: CapabilitySet) -> Self
pub fn root(budget: BudgetTracker, capabilities: CapabilitySet) -> Self
Creates a root run context.
Sourcepub const fn parent_run_id(&self) -> Option<RunId>
pub const fn parent_run_id(&self) -> Option<RunId>
Returns this run’s parent identity.
Sourcepub const fn root_run_id(&self) -> RunId
pub const fn root_run_id(&self) -> RunId
Returns the root run identity.
Sourcepub const fn caused_by(&self) -> Option<EventId>
pub const fn caused_by(&self) -> Option<EventId>
Returns the event that caused this run to start, when known.
Sourcepub const fn cancellation(&self) -> &CancellationToken
pub const fn cancellation(&self) -> &CancellationToken
Returns the hierarchical cancellation token.
Sourcepub const fn budget(&self) -> &BudgetTracker
pub const fn budget(&self) -> &BudgetTracker
Returns the shared run-tree budget tracker.
Sourcepub const fn capabilities(&self) -> &CapabilitySet
pub const fn capabilities(&self) -> &CapabilitySet
Returns capabilities explicitly granted to this run.
Sourcepub const fn metadata_mut(&mut self) -> &mut Metadata
pub const fn metadata_mut(&mut self) -> &mut Metadata
Mutably returns runtime metadata.
Sourcepub const fn recorder(&self) -> Option<&RunRecorder>
pub const fn recorder(&self) -> Option<&RunRecorder>
Returns the configured event recorder, when observability is enabled.
Sourcepub fn with_journal(self, journal: Arc<dyn Journal>) -> Self
pub fn with_journal(self, journal: Arc<dyn Journal>) -> Self
Enables structured event recording for this run and future children.
Sourcepub fn record(
&self,
kind: RunEventKind,
caused_by: Option<EventId>,
) -> Result<Option<RunEvent>, JournalError>
pub fn record( &self, kind: RunEventKind, caused_by: Option<EventId>, ) -> Result<Option<RunEvent>, JournalError>
Records one event when observability is enabled.
§Errors
Returns JournalError when the configured journal rejects the event.
Sourcepub fn with_deadline(self, deadline: Instant) -> Self
pub fn with_deadline(self, deadline: Instant) -> Self
Sets a deadline, clamped to any existing earlier deadline.
Sourcepub const fn with_cause(self, event_id: EventId) -> Self
pub const fn with_cause(self, event_id: EventId) -> Self
Sets the event that caused this run to start.
Sourcepub fn child(&self, capabilities: CapabilitySet) -> Self
pub fn child(&self, capabilities: CapabilitySet) -> Self
Creates a child with an explicit capability set.
The child shares the root budget tracker, receives a descendant cancellation token, and does not inherit metadata or capabilities.
Sourcepub fn child_reserved(
&self,
capabilities: CapabilitySet,
reservation: &BudgetReservation,
) -> Result<Self, BudgetReservationMismatch>
pub fn child_reserved( &self, capabilities: CapabilitySet, reservation: &BudgetReservation, ) -> Result<Self, BudgetReservationMismatch>
Creates a child funded by one scoped reservation from this run tree.
§Errors
Returns BudgetReservationMismatch when the reservation was created
by another run tree.
Trait Implementations§
Source§impl Clone for RunContext
impl Clone for RunContext
Source§fn clone(&self) -> RunContext
fn clone(&self) -> RunContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more