diff options
Diffstat (limited to 'morphology-img/src/render.rs')
| -rw-r--r-- | morphology-img/src/render.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/morphology-img/src/render.rs b/morphology-img/src/render.rs index 189dd61..ca61df4 100644 --- a/morphology-img/src/render.rs +++ b/morphology-img/src/render.rs @@ -138,6 +138,7 @@ pub fn render_ly_to_svg( /// - `ly_files`: Paths to the .ly files to render /// - `output_dir`: Directory where SVGs should be created /// - `lilypond_binary`: Path to the LilyPond binary +/// - `progress_callback`: Optional callback for progress reporting /// /// # Returns /// Vector of paths to generated SVG files, in the same order as input @@ -157,7 +158,7 @@ pub fn render_ly_to_svg( /// let output_dir = Path::new("output"); /// let lilypond = Path::new("lilypond"); /// -/// let svg_paths = render_ly_files_to_svg(&ly_files, output_dir, lilypond).unwrap(); +/// let svg_paths = render_ly_files_to_svg(&ly_files, output_dir, lilypond, None).unwrap(); /// println!("Generated {} SVG files", svg_paths.len()); /// ``` /// @@ -165,16 +166,24 @@ pub fn render_ly_to_svg( /// - Files are processed sequentially (not in parallel) /// - All SVGs are created in the same output directory /// - If any file fails, an error is returned immediately +/// - Progress callback is called after each file is rendered (if provided) pub fn render_ly_files_to_svg( ly_files: &[PathBuf], output_dir: &Path, lilypond_binary: &Path, + progress_callback: Option<&crate::ProgressCallback>, ) -> Result<Vec<PathBuf>, RenderError> { - let mut svg_paths = Vec::with_capacity(ly_files.len()); + let total_count = ly_files.len(); + let mut svg_paths = Vec::with_capacity(total_count); - for ly_file in ly_files { + for (index, ly_file) in ly_files.iter().enumerate() { let svg_path = render_ly_to_svg(ly_file, output_dir, lilypond_binary)?; svg_paths.push(svg_path); + + // Call progress callback if provided + if let Some(callback) = progress_callback { + callback(index + 1, total_count); + } } Ok(svg_paths) |