flow_plots/render/mod.rs
1pub mod plotters_backend;
2pub mod progress;
3
4pub use progress::{ProgressCallback, ProgressInfo};
5
6/// Configuration for plot rendering
7///
8/// This struct allows applications to inject their own execution and progress
9/// reporting logic without the library depending on specific frameworks.
10#[derive(Default)]
11pub struct RenderConfig {
12 /// Optional progress callback for reporting rendering progress
13 ///
14 /// Applications can provide a callback to receive progress updates during
15 /// pixel rendering. This is useful for streaming/progressive rendering.
16 pub progress: Option<ProgressCallback>,
17}
18
19impl RenderConfig {
20 /// Create a new RenderConfig with no callbacks
21 pub fn new() -> Self {
22 Self::default()
23 }
24
25 /// Call the progress callback if present
26 pub fn report_progress(&mut self, info: ProgressInfo) {
27 if let Some(ref mut callback) = self.progress {
28 if let Err(e) = callback(info) {
29 eprintln!("⚠️ Failed to report progress: {}", e);
30 }
31 }
32 }
33}