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,
) -> Result<Self, AuthorityAmplification>
pub fn child( &self, capabilities: CapabilitySet, ) -> Result<Self, AuthorityAmplification>
Creates a child with an explicitly attenuated capability set.
The child shares the root budget tracker, receives a descendant cancellation token, and does not inherit metadata or capabilities.
§Errors
Returns AuthorityAmplification when the child requests any
capability absent from this Run.
Sourcepub fn child_reserved(
&self,
capabilities: CapabilitySet,
reservation: &BudgetReservation,
) -> Result<Self, ChildRunError>
pub fn child_reserved( &self, capabilities: CapabilitySet, reservation: &BudgetReservation, ) -> Result<Self, ChildRunError>
Creates an attenuated child funded by a scoped budget reservation.
§Errors
Returns ChildRunError when the child requests authority absent from
this Run or 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