Skip to main content

RunContext

Struct RunContext 

Source
pub struct RunContext { /* private fields */ }
Expand description

The authority, lifetime, and accounting scope of one run.

Implementations§

Source§

impl RunContext

Source

pub fn root(budget: BudgetTracker, capabilities: CapabilitySet) -> Self

Creates a root run context.

Source

pub const fn run_id(&self) -> RunId

Returns this run’s identity.

Source

pub const fn parent_run_id(&self) -> Option<RunId>

Returns this run’s parent identity.

Source

pub const fn root_run_id(&self) -> RunId

Returns the root run identity.

Source

pub const fn caused_by(&self) -> Option<EventId>

Returns the event that caused this run to start, when known.

Source

pub const fn deadline(&self) -> Option<Instant>

Returns the effective deadline.

Source

pub const fn cancellation(&self) -> &CancellationToken

Returns the hierarchical cancellation token.

Source

pub const fn budget(&self) -> &BudgetTracker

Returns the shared run-tree budget tracker.

Source

pub const fn capabilities(&self) -> &CapabilitySet

Returns capabilities explicitly granted to this run.

Source

pub const fn metadata(&self) -> &Metadata

Returns runtime metadata.

Source

pub const fn metadata_mut(&mut self) -> &mut Metadata

Mutably returns runtime metadata.

Source

pub const fn recorder(&self) -> Option<&RunRecorder>

Returns the configured event recorder, when observability is enabled.

Source

pub fn with_journal(self, journal: Arc<dyn Journal>) -> Self

Enables structured event recording for this run and future children.

Source

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.

Source

pub fn with_deadline(self, deadline: Instant) -> Self

Sets a deadline, clamped to any existing earlier deadline.

Source

pub const fn with_cause(self, event_id: EventId) -> Self

Sets the event that caused this run to start.

Source

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.

Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for RunContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.