Skip to content

Commit b739b2c

Browse files
authored
Debloat & Package maint (#5)
1 parent fc009cb commit b739b2c

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ jobs:
4747
- uses: actions-rs/cargo@v1
4848
with:
4949
command: clippy
50-
args: -- -D warnings
50+
args: --all -- -D warnings

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dmi"
33
version = "0.1.3"
4-
edition = "2018"
4+
edition = "2021"
55
license = "MIT"
66
description = "DMI library written in Rust. Provides helpers to manipulate and produce DMI format files."
77
authors = ["Rohesie <rohesie@gmail.com>"]
@@ -12,6 +12,6 @@ exclude = ["src/tests.rs", "tests/*"]
1212

1313
[dependencies]
1414
thiserror = "1.0"
15-
image = "0.23"
15+
image = { version = "0.24", default-features = false, features = ["png"] }
1616
deflate = "1.0"
1717
inflate = "0.4"

src/dmi/icon.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use image::imageops;
66
use image::GenericImageView;
77
use std::collections::HashMap;
88
use std::io::prelude::*;
9+
use std::io::Cursor;
910

1011
#[derive(Clone, Default)]
1112
pub struct Icon {
@@ -345,14 +346,14 @@ impl Icon {
345346
imageops::replace(
346347
&mut new_png,
347348
*image,
348-
self.width * (index % max_index),
349-
self.height * (index / max_index),
349+
(self.width * (index % max_index)).into(),
350+
(self.height * (index / max_index)).into(),
350351
);
351352
}
352353

353-
let mut new_dmi = vec![];
354-
new_png.write_to(&mut new_dmi, image::ImageOutputFormat::Png)?;
355-
let mut new_dmi = RawDmi::load(&new_dmi[..])?;
354+
let mut dmi_data = Cursor::new(vec![]);
355+
new_png.write_to(&mut dmi_data, image::ImageOutputFormat::Png)?;
356+
let mut new_dmi = RawDmi::load(&dmi_data.into_inner()[..])?;
356357

357358
let new_ztxt = ztxt::create_ztxt_chunk(signature.as_bytes())?;
358359

src/dmi/ztxt.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,10 @@ impl RawZtxtData {
289289
pub fn decode(&self) -> Result<Vec<u8>, error::DmiError> {
290290
match inflate::inflate_bytes_zlib(&self.compressed_text) {
291291
Ok(decompressed_text) => Ok(decompressed_text),
292-
Err(text) => {
293-
return Err(error::DmiError::Generic(format!(
294-
"Failed to read compressed text. Error: {}",
295-
text
296-
)))
297-
}
292+
Err(text) => Err(error::DmiError::Generic(format!(
293+
"Failed to read compressed text. Error: {}",
294+
text
295+
))),
298296
}
299297
}
300298

0 commit comments

Comments
 (0)