From 072f2619bd796d3e6a122d898d4da692bdb05a6e Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 28 Oct 2026 06:09:21 +0000 Subject: [PATCH] Refactor export for strict Clippy checks --- crates/export/src/lib.rs | 19 ++++++++----------- crates/export/tests/it/render_settings.rs | 8 ++++---- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/crates/export/src/lib.rs b/crates/export/src/lib.rs index 9af195204..7ea28b571 100644 --- a/crates/export/src/lib.rs +++ b/crates/export/src/lib.rs @@ -270,7 +270,7 @@ async fn sequence(cx: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut State<'_>) let path = sequence_path(cx.path, f0 + k as i64); // Encode in memory first: the storage hook decides where it fits. let mut buf = std::io::Cursor::new(Vec::new()); - write_still(cx, &mut buf, fmt, &img, comp, channels, w, h, cx.output.quality)?; + write_still(cx, &mut buf, &img, comp, StillOutput { format: fmt, channels, size: (w, h), quality: cx.output.quality })?; let data = buf.into_inner(); let path = cx.place(&path, data.len() as u64); let mut f = cx.create(&path)?; @@ -287,18 +287,15 @@ async fn sequence(cx: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut State<'_>) Ok(Report { path: sequence_path(cx.path, f0), frames: 0, width: w, height: h, seconds: 0.0, bytes, audio: false, log: None, overflow: vec![] }) } -#[allow(clippy::too_many_arguments)] -fn write_still( - cx: &Cx, - file: &mut W, - fmt: OutputFormat, - img: &Image, - comp: &Comp, +struct StillOutput { + format: OutputFormat, channels: Channels, - w: u32, - h: u32, + size: (u32, u32), quality: u8, -) -> Result<()> { +} + +fn write_still(cx: &Cx, file: &mut W, img: &Image, comp: &Comp, output: StillOutput) -> Result<()> { + let StillOutput { format: fmt, channels, size: (w, h), quality } = output; use image::{ExtendedColorType, ImageEncoder, ImageFormat}; match fmt { OutputFormat::ExrSequence => { diff --git a/crates/export/tests/it/render_settings.rs b/crates/export/tests/it/render_settings.rs index 9e9a0a18f..465d8e5fe 100644 --- a/crates/export/tests/it/render_settings.rs +++ b/crates/export/tests/it/render_settings.rs @@ -45,7 +45,7 @@ fn custom(start: f64, end: f64) -> RenderSettings { } fn run_with(p: &Project, cid: ItemId, s: &RenderSettings, om: &OutputModule, path: &str, options: JobOptions, cancel: bool) -> (Result, Files) { - run_on(p, cid, s, om, path, options, None, cancel) + run_on(p, cid, s, om, path, options, (None, cancel)) } /// [`run_with`] with an accelerator. @@ -56,9 +56,9 @@ fn run_on( om: &OutputModule, path: &str, options: JobOptions, - accel: Option<&dyn Accelerator>, - cancel: bool, + execution: (Option<&dyn Accelerator>, bool), ) -> (Result, Files) { + let (accel, cancel) = execution; let files: Files = Default::default(); let f = files.clone(); let sink: Box = Box::new(move |path: &str, data: Vec| f.lock().unwrap().push((path.to_string(), data))); @@ -456,7 +456,7 @@ fn a_job_renders_on_one_compositor() { let om = OutputModule::for_format(OutputFormat::PngSequence); let s = custom(0.0, 0.4); let render = |p: &Project, accel: &GreenAccel, path: &str| { - let (r, files) = run_on(p, cid, &s, &om, path, JobOptions::default(), Some(accel), false); + let (r, files) = run_on(p, cid, &s, &om, path, JobOptions::default(), (Some(accel), false)); r.expect("export"); (0..10).map(|i| png(&files, i)).collect::>() };