pub struct OnceRunResult { /* private fields */ }Expand description
A classified Once completion with one policy-valid scheduling proposal.
Winning exact reconciliation and terminal pending commands discard the proposal before validation. An explicit invariant failure always stops. Other completion classifications preserve the supplied decision: a retryable failure does not automatically retry, and success does not automatically continue.
Construction does not validate relative delays. If the proposal survives
command arbitration, the runtime checks duration encoding and deadline
arithmetic. An invalid selected delay stops the declaration with a
crate::TimerControlFailure; a retained declaration exposes that failure
in its snapshot.
Registration and lifecycle reconstruction use the same typed results:
use ic_timers::{register_once, register_after_completion, reconcile_once,
reconcile_after_completion, OnceDecision, OnceRunResult,
AfterCompletionDecision, AfterCompletionRunResult, TimerIdentity,
TimerCadence, TimerCompletion, TimerReconcileState, DeclarationLifetime, initialize_runtime};
initialize_runtime()?;
let once_identity = TimerIdentity::try_new("app", "jobs", "once").unwrap();
let recurring_identity = TimerIdentity::try_new("app", "jobs", "recurring").unwrap();
let direct_once_identity = TimerIdentity::try_new("app", "jobs", "direct-once").unwrap();
let direct_recurring_identity = TimerIdentity::try_new("app", "jobs", "direct-recurring").unwrap();
let cadence = TimerCadence::from_nanos(5)?;
let _once = register_once(direct_once_identity, DeclarationLifetime::Retained, |_| async {
OnceRunResult::new(TimerCompletion::no_work(), OnceDecision::Stop)
})?;
let _recurring = register_after_completion(direct_recurring_identity, cadence,
DeclarationLifetime::Retained, |_| async {
AfterCompletionRunResult::new(TimerCompletion::no_work(),
AfterCompletionDecision::RecurAfterCompletion)
})?;
let mut once = None;
reconcile_once(&mut once, &once_identity, None, |_| async {
OnceRunResult::new(TimerCompletion::no_work(), OnceDecision::Stop)
})?;
let mut recurring = None;
reconcile_after_completion(&mut recurring, &recurring_identity, cadence,
TimerReconcileState::Inactive, |_| async {
AfterCompletionRunResult::new(TimerCompletion::no_work(), AfterCompletionDecision::Stop)
})?;The result accepts only a OnceDecision:
use ic_timers::{AfterCompletionDecision, OnceRunResult, TimerCompletion};
let result = OnceRunResult::new(
TimerCompletion::no_work(), AfterCompletionDecision::Stop,
);Implementations§
Source§impl OnceRunResult
impl OnceRunResult
Sourcepub const fn new(completion: TimerCompletion, decision: OnceDecision) -> Self
pub const fn new(completion: TimerCompletion, decision: OnceDecision) -> Self
Construct a result, forcing invariant failures to stop.
Sourcepub const fn completion(self) -> TimerCompletion
pub const fn completion(self) -> TimerCompletion
Return the completion classification and reported work count.
Sourcepub const fn decision(self) -> OnceDecision
pub const fn decision(self) -> OnceDecision
Return the post-run scheduling proposal.