Skip to main content

OnceRunResult

Struct OnceRunResult 

Source
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

Source

pub const fn new(completion: TimerCompletion, decision: OnceDecision) -> Self

Construct a result, forcing invariant failures to stop.

Source

pub const fn completion(self) -> TimerCompletion

Return the completion classification and reported work count.

Source

pub const fn decision(self) -> OnceDecision

Return the post-run scheduling proposal.

Trait Implementations§

Source§

impl Clone for OnceRunResult

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 Copy for OnceRunResult

Source§

impl Debug for OnceRunResult

Source§

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

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

impl Eq for OnceRunResult

Source§

impl PartialEq for OnceRunResult

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for OnceRunResult

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.