From b739b2cda26c9d7cb397eab371d928f4b4b4998c Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Wed, 26 Oct 2022 20:31:39 -0700 Subject: [PATCH] Debloat & Package maint (#5) --- .github/workflows/ci.yml | 2 +- Cargo.toml | 4 ++-- src/dmi/icon.rs | 11 ++++++----- src/dmi/ztxt.rs | 10 ++++------ 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c43c8c..cb6f053 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,4 +47,4 @@ jobs: - uses: actions-rs/cargo@v1 with: command: clippy - args: -- -D warnings \ No newline at end of file + args: --all -- -D warnings diff --git a/Cargo.toml b/Cargo.toml index 9ace84c..bee1ff4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dmi" version = "0.1.3" -edition = "2018" +edition = "2021" license = "MIT" description = "DMI library written in Rust. Provides helpers to manipulate and produce DMI format files." authors = ["Rohesie "] @@ -12,6 +12,6 @@ exclude = ["src/tests.rs", "tests/*"] [dependencies] thiserror = "1.0" -image = "0.23" +image = { version = "0.24", default-features = false, features = ["png"] } deflate = "1.0" inflate = "0.4" diff --git a/src/dmi/icon.rs b/src/dmi/icon.rs index b1b30a3..377a6c3 100644 --- a/src/dmi/icon.rs +++ b/src/dmi/icon.rs @@ -6,6 +6,7 @@ use image::imageops; use image::GenericImageView; use std::collections::HashMap; use std::io::prelude::*; +use std::io::Cursor; #[derive(Clone, Default)] pub struct Icon { @@ -345,14 +346,14 @@ impl Icon { imageops::replace( &mut new_png, *image, - self.width * (index % max_index), - self.height * (index / max_index), + (self.width * (index % max_index)).into(), + (self.height * (index / max_index)).into(), ); } - let mut new_dmi = vec![]; - new_png.write_to(&mut new_dmi, image::ImageOutputFormat::Png)?; - let mut new_dmi = RawDmi::load(&new_dmi[..])?; + let mut dmi_data = Cursor::new(vec![]); + new_png.write_to(&mut dmi_data, image::ImageOutputFormat::Png)?; + let mut new_dmi = RawDmi::load(&dmi_data.into_inner()[..])?; let new_ztxt = ztxt::create_ztxt_chunk(signature.as_bytes())?; diff --git a/src/dmi/ztxt.rs b/src/dmi/ztxt.rs index b7238f8..d213768 100644 --- a/src/dmi/ztxt.rs +++ b/src/dmi/ztxt.rs @@ -289,12 +289,10 @@ impl RawZtxtData { pub fn decode(&self) -> Result, error::DmiError> { match inflate::inflate_bytes_zlib(&self.compressed_text) { Ok(decompressed_text) => Ok(decompressed_text), - Err(text) => { - return Err(error::DmiError::Generic(format!( - "Failed to read compressed text. Error: {}", - text - ))) - } + Err(text) => Err(error::DmiError::Generic(format!( + "Failed to read compressed text. Error: {}", + text + ))), } }