rskit_dataset/collector/progress.rs
1//! Progress callback protocol for reporting collection progress.
2
3use crate::manifest::SourceStats;
4use crate::target::PublishResult;
5
6/// Callback protocol for reporting collection progress.
7///
8/// Called **only from the main event loop** — never from worker tasks.
9/// This means implementations do NOT need interior mutability or `Sync`.
10///
11/// All methods have default no-op implementations, so you only override
12/// what you need.
13pub trait ProgressCallback: Send {
14 /// Called when a source starts streaming.
15 fn on_source_start(&self, _index: usize, _name: &str, _max_items: Option<usize>) {}
16 /// Called after a source emits or resumes item progress.
17 fn on_source_progress(&self, _index: usize, _count: usize) {}
18 /// Called when a source finishes successfully or partially.
19 fn on_source_done(&self, _index: usize, _name: &str, _stats: &SourceStats) {}
20 /// Called when a source is skipped from manifest cache.
21 fn on_source_cached(&self, _index: usize, _name: &str, _stats: &SourceStats) {}
22 /// Called when source processing fails.
23 fn on_source_error(&self, _index: usize, _name: &str, _error: &str) {}
24 /// Called before publishing to a target.
25 fn on_publish_start(&self, _target: &str) {}
26 /// Called after a target publishes successfully.
27 fn on_publish_done(&self, _target: &str, _result: &PublishResult) {}
28 /// Called when target publishing fails.
29 fn on_publish_error(&self, _target: &str, _error: &str) {}
30}
31
32/// No-op progress callback (all defaults).
33pub struct NullProgress;
34impl ProgressCallback for NullProgress {}