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 runtime executes `Once`, after-completion, and pre-armed synchronous
9//! 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. Registration capabilities
13//! can observe exact armed provider-wakeup ownership without making snapshots
14//! or observations into scheduling authority.
15//! [`timer_inventory`] returns the epoch together with the complete ordered
16//! timer set, including for an initialized empty registry.
17
18#![forbid(unsafe_code)]
19#![forbid(private_interfaces)]
20#![deny(rustdoc::broken_intra_doc_links)]
21mod callback;
22mod control;
23mod platform;
24mod registry;
25mod runtime;
26mod schedule;
27mod snapshot;
28
29pub use callback::{
30    AfterCompletionDecision, AfterCompletionRunResult, OnceDecision, OnceRunResult,
31};
32pub use registry::{MAX_TIMER_REGISTRATIONS, RegisterError};
33pub use runtime::{
34    AfterCompletionContext, AfterCompletionRegistration, OnceContext, OnceRegistration, TimerError,
35    TimerReconcileState, WatchdogContext, WatchdogReconcileState, WatchdogRegistration,
36    consecutive_expected_failures, initialize_runtime, reconcile_after_completion, reconcile_once,
37    reconcile_watchdog, register_after_completion, register_once, register_watchdog,
38    timer_inventory, timer_snapshot,
39};
40pub use schedule::{ScheduleError, TimerCadence, TimerSchedule};
41pub use snapshot::{
42    DeclarationLifetime, InactiveReason, MAX_TIMER_IDENTITY_COMPONENT_BYTES, MeasurementSummary,
43    MemoryPageExtent, MemoryPageSample, MemoryPageSummary, OrdinaryRuntimeStateSnapshot,
44    TimerCompletion, TimerCompletionOutcome, TimerControlFailure, TimerCounters,
45    TimerDirectiveSnapshot, TimerEpoch, TimerIdentity, TimerIdentityError, TimerIdentityField,
46    TimerInventorySnapshot, TimerLastOutcome, TimerObservabilitySnapshot, TimerOutcomeSnapshot,
47    TimerPerformance, TimerPolicy, TimerProcessCondition, TimerRegistrationId,
48    TimerRegistrationStatus, TimerRuntimeStateSnapshot, TimerSchedulingMode, TimerSnapshot,
49    WatchdogAttemptStatus, WatchdogDecision, WatchdogRunResult, WatchdogRuntimeStateSnapshot,
50};