fix: take care of clippy warnings and add test image

This commit is contained in:
MultisampledNight 2024-01-11 01:36:47 +01:00
commit 816602fb2e
No known key found for this signature in database
GPG key ID: 6D525AA147CBDAE2
7 changed files with 37 additions and 36 deletions

View file

@ -2,8 +2,9 @@ pub mod read {
use image::{io::Reader as ImageReader, DynamicImage};
use rpl::instructions::read::{Read, SourceType};
pub fn read(Read { source, format }: Read) -> DynamicImage {
let mut img = ImageReader::open(match source {
pub fn read(Read { source, format: _ }: Read) -> DynamicImage {
// TODO: actual error handling
let img = ImageReader::open(match source {
SourceType::File(path) => path,
})
.expect("something went wrong :(((");
@ -13,19 +14,21 @@ pub mod read {
}
pub mod write {
use image::{io::Reader as ImageReader, DynamicImage, ImageFormat};
use image::{DynamicImage, ImageFormat};
use rpl::instructions::write::{TargetFormat, TargetType, Write};
pub fn write(Write { target, format }: Write, input_data: DynamicImage) {
input_data.save_with_format(
match target {
TargetType::File(path) => path,
},
match format {
TargetFormat::Jpeg => ImageFormat::Jpeg,
TargetFormat::Png => ImageFormat::Png,
},
);
pub fn write(Write { target, format }: Write, input_data: &DynamicImage) {
input_data
.save_with_format(
match target {
TargetType::File(path) => path,
},
match format {
TargetFormat::Jpeg => ImageFormat::Jpeg,
TargetFormat::Png => ImageFormat::Png,
},
)
.expect("couldn't save file — come back later and handle me properly please uwu");
}
}