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
impl OperationControl
Sourcepub fn child(&self) -> Self
pub fn child(&self) -> Self
Creates an independently cancellable child that observes this control’s cancellation and deadline state.
Sourcepub fn for_phase(&self, phase: OperationPhase) -> Self
pub fn for_phase(&self, phase: OperationPhase) -> Self
Creates a shared view whose unnamed checkpoints report the supplied operation phase.
Sourcepub fn with_deadline(self, timeout: Duration) -> Self
pub fn with_deadline(self, timeout: Duration) -> Self
Sets a relative monotonic deadline if one is not already configured.
Sourcepub fn set_deadline(&self, timeout: Duration) -> bool
pub fn set_deadline(&self, timeout: Duration) -> bool
Sets a relative monotonic deadline, returning whether this call installed it.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns whether this control or an ancestor has received a cancellation request.
Sourcepub fn checkpoint(&self) -> Result<(), OperationCancelled>
pub fn checkpoint(&self) -> Result<(), OperationCancelled>
Checks cancellation/deadline at an unspecified phase.
Sourcepub fn checkpoint_at(
&self,
phase: OperationPhase,
) -> Result<(), OperationCancelled>
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.
Sourcepub fn terminal_checkpoint_at(
&self,
phase: OperationPhase,
) -> Result<(), OperationLedgerError>
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.
Sourcepub fn terminate_resource_limit(
&self,
error: OperationResourceLimitExceeded,
) -> OperationLedgerError
pub fn terminate_resource_limit( &self, error: OperationResourceLimitExceeded, ) -> OperationLedgerError
Records a target-owned resource ceiling as this operation’s first terminal outcome.
Sourcepub fn terminate_resource_overflow(
&self,
id: &'static str,
phase: OperationPhase,
resource_phase: &'static str,
actual: u64,
maximum: u64,
provenance: OperationResourceProvenance,
) -> OperationLedgerError
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.