canic_core/ops/sync/
mod.rs

1//! Synchronization helpers for propagating state and topology snapshots.
2
3pub mod state;
4pub mod topology;
5
6use crate::{Error, ThisError, log, log::Topic, ops::OpsError};
7use candid::Principal;
8
9const SYNC_CALL_WARN_THRESHOLD: usize = 10;
10
11///
12/// SyncOpsError
13/// Errors raised during synchronization
14///
15
16#[derive(Debug, ThisError)]
17pub enum SyncOpsError {
18    #[error("canister not found")]
19    CanisterNotFound(Principal),
20
21    #[error("root canister not found")]
22    RootNotFound,
23}
24
25impl From<SyncOpsError> for Error {
26    fn from(err: SyncOpsError) -> Self {
27        OpsError::from(err).into()
28    }
29}
30
31///
32/// Helpers
33///
34
35fn warn_if_large(label: &str, count: usize) {
36    if count > SYNC_CALL_WARN_THRESHOLD {
37        log!(
38            Topic::Sync,
39            Warn,
40            "sync: large {}: {} entries",
41            label,
42            count
43        );
44    }
45}