Problem
The rust/periodic_tasks/timer example uses ic-cdk-timers = "0.6" and the old closure-based API. The ic-cdk-timers v1.0.0 release (2025-11-13) introduced breaking changes to function signatures.
What needs updating
Dependencies (timer/Cargo.toml)
ic-cdk 0.12 → 0.19
ic-cdk-macros 0.8 → current
ic-cdk-timers 0.6 → 1.0
Code (timer/src/lib.rs)
set_timer_interval signature changed — now takes FnMut() -> impl Future instead of FnOnce():
// Old (line 71):
let timer_id = ic_cdk_timers::set_timer_interval(secs, periodic_task);
// New:
let timer_id = ic_cdk_timers::set_timer_interval(secs, || async { periodic_task() });
ic_cdk::spawn() comment is obsolete (lines 75-77) — set_timer now takes futures directly, no spawn wrapper needed.
dfx references in doc comments (lines 53, 65, 82, 96) — dfx is deprecated, should use icp CLI.
Heartbeat example (heartbeat/Cargo.toml)
- Same outdated
ic-cdk/ic-cdk-macros versions
Project-level
dfx.json at project root — should be migrated to icp.yaml
References
Problem
The
rust/periodic_tasks/timerexample usesic-cdk-timers = "0.6"and the old closure-based API. Theic-cdk-timersv1.0.0 release (2025-11-13) introduced breaking changes to function signatures.What needs updating
Dependencies (
timer/Cargo.toml)ic-cdk0.12→0.19ic-cdk-macros0.8→ currentic-cdk-timers0.6→1.0Code (
timer/src/lib.rs)set_timer_intervalsignature changed — now takesFnMut() -> impl Futureinstead ofFnOnce():ic_cdk::spawn()comment is obsolete (lines 75-77) —set_timernow takes futures directly, no spawn wrapper needed.dfxreferences in doc comments (lines 53, 65, 82, 96) —dfxis deprecated, should useicpCLI.Heartbeat example (
heartbeat/Cargo.toml)ic-cdk/ic-cdk-macrosversionsProject-level
dfx.jsonat project root — should be migrated toicp.yamlReferences