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//! desired registrations during their existing lifecycle hooks.
12
13#![forbid(unsafe_code)]
14#![deny(rustdoc::broken_intra_doc_links)]
15
16mod control;
17mod platform;
18pub(crate) mod registry;
19mod runtime;
20pub mod schedule;
21pub mod snapshot;
22
23use control::{TimerControl, TimerControlAction, TimerControlError, TimerRegistration};
24pub use registry::{MAX_TIMER_REGISTRATIONS, RegisterError};
25pub use runtime::{
26    AfterCompletionRegistration, OnceRegistration, TimerContext, TimerError, TimerFuture,
27    TimerReconcileState, WatchdogRegistration, consecutive_expected_failures, initialize_runtime,
28    reconcile_after_completion, reconcile_once, reconcile_watchdog, register_after_completion,
29    register_once, register_watchdog, timer_snapshot, timer_snapshots,
30};
31pub use schedule::{ScheduleError, TimerCadence, TimerDirective, TimerSchedule};
32pub use snapshot::{
33    DeclarationLifetime, InactiveReason, MAX_TIMER_LABEL_BYTES, MeasurementSummary,
34    OrdinaryRuntimeStateSnapshot, TimerCompletion, TimerCompletionOutcome, TimerControlFailure,
35    TimerCounters, TimerDirectiveSnapshot, TimerEpoch, TimerIdentity, TimerIdentityError,
36    TimerIdentityField, TimerLabel, TimerLabelError, TimerLastOutcome, TimerObservabilitySnapshot,
37    TimerOutcomeSnapshot, TimerPerformance, TimerPolicy, TimerProcessCondition,
38    TimerRegistrationStatus, TimerRunResult, TimerRuntimeStateSnapshot, TimerSchedulingMode,
39    TimerSnapshot, WatchdogAttemptSnapshot, WatchdogAttemptStatus, WatchdogDecision,
40    WatchdogRunResult, WatchdogRuntimeStateSnapshot,
41};