fix: clippy warnings in wrapup compute + renderer
Some checks failed
CI / Check / Test (push) Has been cancelled

This commit is contained in:
2026-06-02 23:49:39 +02:00
parent e69f77a99f
commit 9e13f04e9c
6 changed files with 65 additions and 58 deletions

View File

@@ -10,17 +10,11 @@ pub fn render_genre_chart(
let mut buf = vec![0u8; (width * height * 3) as usize];
{
let root =
BitMapBackend::with_buffer(&mut buf, (width, height)).into_drawing_area();
let root = BitMapBackend::with_buffer(&mut buf, (width, height)).into_drawing_area();
root.fill(&RGBColor(26, 26, 36))
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
let max_count = report
.top_genres
.iter()
.map(|g| g.count)
.max()
.unwrap_or(1);
let max_count = report.top_genres.iter().map(|g| g.count).max().unwrap_or(1);
let mut chart = ChartBuilder::on(&root)
.margin(40)
@@ -36,7 +30,7 @@ pub fn render_genre_chart(
.configure_mesh()
.disable_mesh()
.label_style(("sans-serif", 14, &WHITE))
.axis_style(&RGBColor(100, 100, 100))
.axis_style(RGBColor(100, 100, 100))
.draw()
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;

View File

@@ -6,14 +6,12 @@ pub async fn stitch_slides(
slides: &[Vec<u8>],
config: &VideoRenderConfig,
) -> Result<Vec<u8>, DomainError> {
let dir =
tempfile::tempdir().map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
let dir = tempfile::tempdir().map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
// Write slide PNGs
for (i, png) in slides.iter().enumerate() {
let path = dir.path().join(format!("slide_{:04}.png", i));
std::fs::write(&path, png)
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
std::fs::write(&path, png).map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
}
let output_path = dir.path().join("output.mp4");

View File

@@ -7,6 +7,7 @@ use domain::errors::DomainError;
use domain::models::wrapup::WrapUpReport;
use domain::ports::{VideoRenderConfig, WrapUpVideoRenderer};
#[derive(Default)]
pub struct FfmpegWrapUpRenderer;
impl FfmpegWrapUpRenderer {
@@ -25,10 +26,8 @@ impl WrapUpVideoRenderer for FfmpegWrapUpRenderer {
) -> Result<Vec<u8>, DomainError> {
let (width, height) = config.resolution;
let renderer = slides::SlideRenderer::new(
config.font_path.as_deref(),
config.logo_path.as_deref(),
)?;
let renderer =
slides::SlideRenderer::new(config.font_path.as_deref(), config.logo_path.as_deref())?;
// 1. Generate slide images
let mut slide_pngs = Vec::new();

View File

@@ -144,7 +144,13 @@ impl SlideRenderer {
}
// rating distribution bars
let max_count = report.rating_distribution.iter().copied().max().unwrap_or(1).max(1);
let max_count = report
.rating_distribution
.iter()
.copied()
.max()
.unwrap_or(1)
.max(1);
let bar_area_top = (h / 2) as i32;
let bar_h = 36u32;
let bar_gap = 16u32;
@@ -165,11 +171,7 @@ impl SlideRenderer {
// filled bar
let fill_w = ((count as f32 / max_count as f32) * max_bar_w as f32) as u32;
if fill_w > 0 {
draw_filled_rect_mut(
&mut img,
Rect::at(margin_x, y).of_size(fill_w, bar_h),
GOLD,
);
draw_filled_rect_mut(&mut img, Rect::at(margin_x, y).of_size(fill_w, bar_h), GOLD);
}
// count label
let count_s = count.to_string();
@@ -336,11 +338,8 @@ fn fill(w: u32, h: u32) -> RgbaImage {
fn to_png(img: &RgbaImage) -> Result<Vec<u8>, DomainError> {
let mut buf = Vec::new();
img.write_to(
&mut std::io::Cursor::new(&mut buf),
image::ImageFormat::Png,
)
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
img.write_to(&mut std::io::Cursor::new(&mut buf), image::ImageFormat::Png)
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
Ok(buf)
}
@@ -355,11 +354,11 @@ fn load_system_font() -> Result<FontArc, DomainError> {
"/System/Library/Fonts/Helvetica.ttc",
];
for path in &candidates {
if let Ok(bytes) = std::fs::read(path) {
if let Ok(font) = FontArc::try_from_vec(bytes) {
tracing::info!("loaded system font: {path}");
return Ok(font);
}
if let Ok(bytes) = std::fs::read(path)
&& let Ok(font) = FontArc::try_from_vec(bytes)
{
tracing::info!("loaded system font: {path}");
return Ok(font);
}
}
Err(DomainError::InfrastructureError(