From f3149597c786da35d57f44d5de2ad602cc072d10 Mon Sep 17 00:00:00 2001 From: Parker B <20159000+jpburnett@users.noreply.github.com> Date: Tue, 2 Apr 2024 19:59:16 -0700 Subject: [PATCH] Address review comments This commit removes the implemented functions. Also updates the README.md description. --- README.md | 2 +- src/lib.rs | 48 ++++++++++--------------------------------- tests/native_image.rs | 3 ++- 3 files changed, 14 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index b7c78eb..9061328 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # pigment64 -pigment64 is a library written in Rust for decoding N64 images in to pngs. +pigment64 is a library written in Rust for converting image data between native and png formats. ## Formats The library supports the following image formats: diff --git a/src/lib.rs b/src/lib.rs index e3bd326..65a74d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,10 +9,7 @@ pub use image::png_image::PNGImage; mod utils; -use strum:: { - EnumCount, IntoEnumIterator -}; -use strum_macros::{EnumCount as EnumCountMacro, EnumIter}; +use strum_macros::{EnumCount, EnumIter}; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TryFromPrimitive)] #[repr(u8)] @@ -26,6 +23,15 @@ pub enum ImageSize { } impl ImageSize { + /// Returns the size of the TLUT (Table Look-Up Table) based on the image size. + /// + /// # Returns + /// + /// The size of the TLUT as a `usize` value. + /// + /// # Panics + /// + /// This method will panic if the image size is invalid. pub fn get_tlut_size(&self) -> usize { match self { ImageSize::Bits1 => 0b10, @@ -55,7 +61,7 @@ pub enum ImageFormat { /// Each variant corresponds to a specific image type, such as indexed color (Ci), grayscale (I), /// grayscale with alpha (Ia), or red-green-blue-alpha (RGBA). /// -#[derive(Copy, Clone, Debug, PartialEq, EnumCountMacro, EnumIter, Eq, Hash, TryFromPrimitive)] +#[derive(Copy, Clone, Debug, PartialEq, EnumCount, EnumIter, Eq, Hash, TryFromPrimitive)] #[repr(u8)] pub enum ImageType { I1, @@ -116,38 +122,6 @@ impl ImageType { ImageType::Rgba32 => ImageFormat::Rgba, } } - - /// Returns the number of variants in the `ImageType` enum. - /// - /// # Examples - /// - /// ``` - /// use pigment64::ImageType; - /// - /// // Get the count of ImageType variants - /// let count = ImageType::get_image_type_count(); - /// println!("Number of ImageType variants: {}", count); - /// ``` - pub fn get_count() -> usize { - ImageType::COUNT - } - - /// Returns an iterator over all possible variants of `ImageType`, converted to their formatted - /// string representations. - /// - /// # Examples - /// ``` - /// use pigment64::ImageType; - /// - /// // Iterate over the image formats - /// for image_format_type in ImageType::format_iter() { - /// println!("{}", image_format_type); - /// } - /// ``` - pub fn get_iter() -> impl Iterator { - ImageType::iter().into_iter() - } - } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive)] diff --git a/tests/native_image.rs b/tests/native_image.rs index 2ffb83e..a6a8ffd 100644 --- a/tests/native_image.rs +++ b/tests/native_image.rs @@ -165,8 +165,9 @@ fn rgba32() -> Result<()> { } #[test] -fn test_format_names() { +fn test_image_type_strum() { + // Test iterating over the ImageType enum let mut image_iter = ImageType::iter(); assert_eq!(Some(ImageType::I1), image_iter.next()); assert_eq!(Some(ImageType::I4), image_iter.next());