Skip to main content

OperationControl

Struct OperationControl 

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

Cloneable operation-scoped cooperative cancellation and deadline control.

A synchronous callback cannot be forcefully interrupted. It observes a request when it returns to a checkpoint. Cancellation, deadlines, resource ceilings, and resource arithmetic failures compete for one sticky terminal outcome per operation scope.

Implementations§

Source§

impl OperationControl

Source

pub fn new() -> Self

Creates active control using the platform monotonic clock.

Source

pub fn child(&self) -> Self

Creates an independently cancellable child that observes this control’s cancellation and deadline state.

Source

pub fn for_phase(&self, phase: OperationPhase) -> Self

Creates a shared view whose unnamed checkpoints report the supplied operation phase.

Source

pub fn with_deadline(self, timeout: Duration) -> Self

Sets a relative monotonic deadline if one is not already configured.

Source

pub fn set_deadline(&self, timeout: Duration) -> bool

Sets a relative monotonic deadline, returning whether this call installed it.

Source

pub fn cancel(&self)

Requests cancellation for this control and its clones.

Source

pub fn is_cancelled(&self) -> bool

Returns whether this control or an ancestor has received a cancellation request.

Source

pub fn checkpoint(&self) -> Result<(), OperationCancelled>

Checks cancellation/deadline at an unspecified phase.

Source

pub fn checkpoint_at( &self, phase: OperationPhase, ) -> Result<(), OperationCancelled>

Checks cancellation/deadline at a named phase.

This cancellation-only projection is used by parsing and analysis code that cannot produce resource terminals. If a target adapter has already recorded a non-cancellation terminal, this method does not replace it with a later cancellation. Target adapters use Self::terminal_checkpoint_at to replay the complete terminal value.

Source

pub fn terminal_checkpoint_at( &self, phase: OperationPhase, ) -> Result<(), OperationLedgerError>

Checks cancellation, deadlines, and any previously observed operation terminal.

Target adapters call this before formal charges and controlled work. Speculative estimates that may be discarded may use Self::checkpoint_at, but they must not record a resource terminal.

Source

pub fn terminate_resource_limit( &self, error: OperationResourceLimitExceeded, ) -> OperationLedgerError

Records a target-owned resource ceiling as this operation’s first terminal outcome.

Source

pub fn terminate_resource_overflow( &self, id: &'static str, phase: OperationPhase, resource_phase: &'static str, actual: u64, maximum: u64, provenance: OperationResourceProvenance, ) -> OperationLedgerError

Records target-owned resource accounting overflow as this operation’s first terminal outcome.

Trait Implementations§

Source§

impl Clone for OperationControl

Source§

fn clone(&self) -> Self

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 OperationControl

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for OperationControl

Source§

fn default() -> Self

Returns the “default value” for a type. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.