Skip to main content

pulsedb/sync/
progress.rs

1//! Progress callback for initial sync operations.
2//!
3//! Consumers implement [`SyncProgressCallback`] to receive progress updates
4//! during [`SyncManager::initial_sync()`](super::manager::SyncManager::initial_sync),
5//! typically for driving a loading bar in the UI.
6
7/// Callback for reporting sync progress during initial catchup.
8///
9/// Implement this trait to receive updates as batches of changes are
10/// pulled and applied during initial sync.
11///
12/// # Example
13///
14/// ```rust
15/// use pulsedb::sync::progress::SyncProgressCallback;
16///
17/// struct ProgressBar;
18///
19/// impl SyncProgressCallback for ProgressBar {
20///     fn on_progress(&self, batch_complete: usize, total_pulled: usize, has_more: bool) {
21///         println!("Pulled {} changes (batch of {}), more: {}", total_pulled, batch_complete, has_more);
22///     }
23/// }
24/// ```
25pub trait SyncProgressCallback: Send {
26    /// Called after each batch of changes is pulled and applied.
27    ///
28    /// # Arguments
29    ///
30    /// * `batch_complete` — Number of changes in the batch just applied
31    /// * `total_pulled` — Cumulative count of all changes pulled so far
32    /// * `has_more` — Whether the remote has more changes to send
33    fn on_progress(&self, batch_complete: usize, total_pulled: usize, has_more: bool);
34}