Skip to main content

ic_timers/
lib.rs

1//! Observable and recovery-aware timer primitives for Internet Computer
2//! canisters.
3//!
4//! `ic-timers` is a higher-level wrapper around `ic-cdk-timers`, which remains
5//! the provider that arms and clears platform timers. This crate adds
6//! bounded coordination, scheduling, and observation above it.
7//!
8//! The 0.3 runtime executes `Once`, after-completion, and pre-armed
9//! synchronous watchdog callbacks through one volatile canister-local registry.
10//! Consumers retain durable application authority and synchronously reconstruct
11//! retained registrations during their existing lifecycle hooks. Transient
12//! remove-on-stop callbacks use direct registration.
13
14#![forbid(unsafe_code)]
15#![deny(rustdoc::broken_intra_doc_links)]
16
17mod control;
18mod platform;
19pub(crate) mod registry;
20mod runtime;
21pub mod schedule;
22pub mod snapshot;
23
24use control::{TimerControl, TimerControlAction, TimerControlError, TimerRegistration};
25pub use registry::{MAX_TIMER_REGISTRATIONS, RegisterError};
26pub use runtime::{
27    AfterCompletionRegistration, OnceRegistration, TimerContext, TimerError, TimerFuture,
28    TimerReconcileState, WatchdogRegistration, consecutive_expected_failures, initialize_runtime,
29    reconcile_after_completion, reconcile_once, reconcile_watchdog, register_after_completion,
30    register_once, register_watchdog, timer_snapshot, timer_snapshots,
31};
32pub use schedule::{ScheduleError, TimerCadence, TimerDirective, TimerSchedule};
33pub use snapshot::{
34    DeclarationLifetime, InactiveReason, MAX_TIMER_LABEL_BYTES, MeasurementSummary,
35    OrdinaryRuntimeStateSnapshot, TimerCompletion, TimerCompletionOutcome, TimerControlFailure,
36    TimerCounters, TimerDirectiveSnapshot, TimerEpoch, TimerIdentity, TimerIdentityError,
37    TimerIdentityField, TimerLabel, TimerLabelError, TimerLastOutcome, TimerObservabilitySnapshot,
38    TimerOutcomeSnapshot, TimerPerformance, TimerPolicy, TimerProcessCondition,
39    TimerRegistrationStatus, TimerRunResult, TimerRuntimeStateSnapshot, TimerSchedulingMode,
40    TimerSnapshot, WatchdogAttemptSnapshot, WatchdogAttemptStatus, WatchdogDecision,
41    WatchdogRunResult, WatchdogRuntimeStateSnapshot,
42};