dataprof_core/
progress.rs1use std::fmt;
2use std::sync::Arc;
3use std::time::Duration;
4
5#[derive(Debug, Clone)]
7pub enum ProgressEvent {
8 Started {
10 estimated_total_rows: Option<usize>,
11 estimated_total_bytes: Option<u64>,
12 },
13 ChunkProcessed {
15 rows_processed: usize,
16 bytes_consumed: u64,
17 elapsed: Duration,
18 processing_speed: f64,
19 percentage: Option<f64>,
20 },
21 SchemaDetected { column_names: Vec<String> },
23 Finished {
25 total_rows: usize,
26 total_bytes: u64,
27 elapsed: Duration,
28 truncated: bool,
29 },
30 Warning { message: String },
32}
33
34#[derive(Clone, Default)]
38pub enum ProgressSink {
39 #[default]
41 None,
42 Callback(Arc<dyn Fn(ProgressEvent) + Send + Sync>),
44 #[cfg(feature = "async-streaming")]
46 Channel(tokio::sync::mpsc::Sender<ProgressEvent>),
47}
48
49impl fmt::Debug for ProgressSink {
50 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51 match self {
52 Self::None => write!(f, "ProgressSink::None"),
53 Self::Callback(_) => write!(f, "ProgressSink::Callback(..)"),
54 #[cfg(feature = "async-streaming")]
55 Self::Channel(_) => write!(f, "ProgressSink::Channel(..)"),
56 }
57 }
58}