Skip to main content

atomic_progress/frontends/
mod.rs

1//! Renderers and traits for visualizing progress.
2//!
3//! This module provides the [`Frontend`] trait, allowing you to implement custom
4//! display logic for your progress trackers.
5
6#[cfg(feature = "terminal")]
7pub mod terminal;
8
9use std::io;
10
11use super::{ProgressSnapshot, ProgressStackSnapshot};
12
13/// A trait for rendering progress state.
14///
15/// By implementing this trait, you can direct progress updates to any output
16/// mechanism: a terminal, a GUI framework, a log file, or a network socket.
17pub trait Frontend {
18    /// Renders a single progress snapshot.
19    fn render(&mut self, snapshot: &ProgressSnapshot) -> io::Result<()>;
20
21    /// Renders a snapshot of a progress stack (multiple trackers).
22    fn render_stack(&mut self, stack_snapshot: &ProgressStackSnapshot) -> io::Result<()>;
23
24    /// Clears the rendered progress indicators from the screen.
25    fn clear(&mut self) -> io::Result<()>;
26
27    /// Signals that progress tracking is finished, allowing the frontend
28    /// to clean up or flush its output.
29    fn finish(&mut self) -> io::Result<()>;
30}