Skip to main content

aether_renderer_core/
report.rs

1use std::path::PathBuf;
2
3#[derive(Debug)]
4pub struct RenderReport {
5    pub output_path: PathBuf,
6    pub frames_rendered: Option<usize>,
7    pub ffmpeg_warnings: Vec<String>,
8    pub preview: bool,
9    pub notes: Option<String>,
10}
11
12impl RenderReport {
13    pub fn new(
14        output_path: PathBuf,
15        frames_rendered: Option<usize>,
16        ffmpeg_warnings: Vec<String>,
17        preview: bool,
18        notes: Option<String>,
19    ) -> Self {
20        Self {
21            output_path,
22            frames_rendered,
23            ffmpeg_warnings,
24            preview,
25            notes,
26        }
27    }
28
29    pub fn summary(&self) -> String {
30        let mut summary = format!("✅ Rendered to: {}\n", self.output_path.display());
31
32        if let Some(frames) = self.frames_rendered {
33            summary.push_str(&format!("Frames rendered: {}\n", frames));
34        } else {
35            summary.push_str("Frames rendered: Unknown\n");
36        }
37
38        if !self.ffmpeg_warnings.is_empty() {
39            summary.push_str("⚠️ FFmpeg Warnings:\n");
40            for warning in &self.ffmpeg_warnings {
41                summary.push_str(&format!("- {}\n", warning));
42            }
43        }
44
45        if self.preview {
46            summary.push_str("🔍 Preview mode enabled.\n");
47        }
48
49        if let Some(notes) = &self.notes {
50            summary.push_str(&format!("📝 Notes: {}\n", notes));
51        }
52
53        summary
54    }
55}
56
57/// How far a render has come, passed to the callback of
58/// [`render_with_progress`](crate::render_with_progress).
59#[derive(Debug, Clone, Copy, PartialEq, serde::Serialize)]
60pub struct RenderProgress {
61    /// Frames encoded so far
62    pub frame: u32,
63    /// Frames in the sequence
64    pub total_frames: u32,
65    /// 0.0 – 100.0, rounded to two decimals
66    pub percent: f64,
67}
68
69impl RenderProgress {
70    pub fn new(frame: u32, total_frames: u32) -> Self {
71        let frame = frame.min(total_frames);
72        let percent = if total_frames == 0 {
73            100.0
74        } else {
75            (frame as f64 * 10_000.0 / total_frames as f64).round() / 100.0
76        };
77        Self {
78            frame,
79            total_frames,
80            percent,
81        }
82    }
83}