From 3c0f5e19be57a3a65e9d4eb06735257187745bf1 Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Tue, 24 Aug 2021 22:45:37 -0400 Subject: [PATCH] Add Debug to more structs --- src/logic/id3/v2/mod.rs | 4 ++-- src/logic/id3/v2/util/encapsulated_object.rs | 2 +- src/logic/id3/v2/util/sync_text.rs | 6 +++--- src/logic/id3/v2/util/text_utils.rs | 2 +- src/types/item.rs | 2 +- src/types/tag.rs | 11 ++++++++--- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/logic/id3/v2/mod.rs b/src/logic/id3/v2/mod.rs index a7cee10a..c80fab3c 100644 --- a/src/logic/id3/v2/mod.rs +++ b/src/logic/id3/v2/mod.rs @@ -49,7 +49,7 @@ impl TextEncoding { } } -#[derive(PartialEq, Clone)] +#[derive(PartialEq, Clone, Debug)] /// Information about an ID3v2 frame that requires a language pub struct LanguageSpecificFrame { /// The encoding of the description and comment text @@ -60,7 +60,7 @@ pub struct LanguageSpecificFrame { description: Option, } -#[derive(PartialEq, Clone)] +#[derive(PartialEq, Clone, Debug)] /// Different types of ID3v2 frames that require varying amounts of information pub enum Id3v2Frame { /// Represents a "COMM" frame diff --git a/src/logic/id3/v2/util/encapsulated_object.rs b/src/logic/id3/v2/util/encapsulated_object.rs index f46f94aa..36cb5791 100644 --- a/src/logic/id3/v2/util/encapsulated_object.rs +++ b/src/logic/id3/v2/util/encapsulated_object.rs @@ -4,7 +4,7 @@ use crate::logic::id3::v2::TextEncoding; use std::io::{Cursor, Read}; -#[derive(PartialEq, Clone)] +#[derive(PartialEq, Clone, Debug)] /// Information about a [`GeneralEncapsulatedObject`] pub struct GEOBInformation { /// The text encoding of `file_name` and `description` diff --git a/src/logic/id3/v2/util/sync_text.rs b/src/logic/id3/v2/util/sync_text.rs index 4029dccc..87c1f686 100644 --- a/src/logic/id3/v2/util/sync_text.rs +++ b/src/logic/id3/v2/util/sync_text.rs @@ -8,7 +8,7 @@ use std::io::{Cursor, Read, Seek, SeekFrom, Write}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Debug)] /// The unit used for [`SynchronizedText`] timestamps pub enum TimestampFormat { /// The unit is MPEG frames @@ -28,7 +28,7 @@ impl TimestampFormat { } } -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Debug)] #[allow(missing_docs)] /// The type of text stored in a [`SynchronizedText`] pub enum SyncTextContentType { @@ -61,7 +61,7 @@ impl SyncTextContentType { } } -#[derive(PartialEq, Clone)] +#[derive(PartialEq, Clone, Debug)] /// Information about a [`SynchronizedText`] pub struct SyncTextInformation { /// The text encoding (description/text) diff --git a/src/logic/id3/v2/util/text_utils.rs b/src/logic/id3/v2/util/text_utils.rs index e784e390..b207ace8 100644 --- a/src/logic/id3/v2/util/text_utils.rs +++ b/src/logic/id3/v2/util/text_utils.rs @@ -53,7 +53,7 @@ where } pub(crate) fn utf16_decode(reader: &[u8], endianness: fn([u8; 2]) -> u16) -> Result { - if reader.len() == 0 || reader.len() % 2 != 0 { + if reader.is_empty() || reader.len() % 2 != 0 { return Err(LoftyError::TextDecode("UTF-16 string has an odd length")); } diff --git a/src/types/item.rs b/src/types/item.rs index d891ed66..1819849b 100644 --- a/src/types/item.rs +++ b/src/types/item.rs @@ -22,7 +22,7 @@ macro_rules! first_key { // Keys should appear in order of popularity. macro_rules! item_keys { (ALLOWED_UNKNOWN => [$($unknown_tag_type:pat),+]; $($variant:ident => [$($($tag_type:pat)|* => $($key:tt)|+),+]),+) => { - #[derive(PartialEq, Clone)] + #[derive(PartialEq, Clone, Debug)] #[allow(missing_docs)] #[non_exhaustive] /// A generic representation of a tag's key diff --git a/src/types/tag.rs b/src/types/tag.rs index c76dfefa..58957b6c 100644 --- a/src/types/tag.rs +++ b/src/types/tag.rs @@ -36,7 +36,7 @@ macro_rules! common_items { } } -#[derive(Clone)] +#[derive(Clone, Debug)] #[allow(clippy::struct_excessive_bools)] /// **(ID3v2/APEv2 ONLY)** Various flags to describe the content of an item /// @@ -95,7 +95,7 @@ impl Default for TagItemFlags { } } -#[derive(Clone)] +#[derive(Clone, Debug)] /// Represents a tag item (key/value) pub struct TagItem { item_key: ItemKey, @@ -157,7 +157,7 @@ impl TagItem { } } -#[derive(Clone)] +#[derive(Clone, Debug)] /// Represents a tag item's value /// /// NOTES: @@ -288,6 +288,11 @@ impl Tag { pub fn item_count(&self) -> u32 { self.items.len() as u32 } + + /// Returns the [`TagFlags`] + pub fn flags(&self) -> &TagFlags { + &self.flags + } } impl Tag {