Add Debug to more structs

This commit is contained in:
Serial 2021-08-24 22:45:37 -04:00
parent 1d5896ed27
commit 3c0f5e19be
6 changed files with 16 additions and 11 deletions

View file

@ -49,7 +49,7 @@ impl TextEncoding {
} }
} }
#[derive(PartialEq, Clone)] #[derive(PartialEq, Clone, Debug)]
/// Information about an ID3v2 frame that requires a language /// Information about an ID3v2 frame that requires a language
pub struct LanguageSpecificFrame { pub struct LanguageSpecificFrame {
/// The encoding of the description and comment text /// The encoding of the description and comment text
@ -60,7 +60,7 @@ pub struct LanguageSpecificFrame {
description: Option<String>, description: Option<String>,
} }
#[derive(PartialEq, Clone)] #[derive(PartialEq, Clone, Debug)]
/// Different types of ID3v2 frames that require varying amounts of information /// Different types of ID3v2 frames that require varying amounts of information
pub enum Id3v2Frame { pub enum Id3v2Frame {
/// Represents a "COMM" frame /// Represents a "COMM" frame

View file

@ -4,7 +4,7 @@ use crate::logic::id3::v2::TextEncoding;
use std::io::{Cursor, Read}; use std::io::{Cursor, Read};
#[derive(PartialEq, Clone)] #[derive(PartialEq, Clone, Debug)]
/// Information about a [`GeneralEncapsulatedObject`] /// Information about a [`GeneralEncapsulatedObject`]
pub struct GEOBInformation { pub struct GEOBInformation {
/// The text encoding of `file_name` and `description` /// The text encoding of `file_name` and `description`

View file

@ -8,7 +8,7 @@ use std::io::{Cursor, Read, Seek, SeekFrom, Write};
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
#[derive(Copy, Clone, PartialEq)] #[derive(Copy, Clone, PartialEq, Debug)]
/// The unit used for [`SynchronizedText`] timestamps /// The unit used for [`SynchronizedText`] timestamps
pub enum TimestampFormat { pub enum TimestampFormat {
/// The unit is MPEG frames /// The unit is MPEG frames
@ -28,7 +28,7 @@ impl TimestampFormat {
} }
} }
#[derive(Copy, Clone, PartialEq)] #[derive(Copy, Clone, PartialEq, Debug)]
#[allow(missing_docs)] #[allow(missing_docs)]
/// The type of text stored in a [`SynchronizedText`] /// The type of text stored in a [`SynchronizedText`]
pub enum SyncTextContentType { pub enum SyncTextContentType {
@ -61,7 +61,7 @@ impl SyncTextContentType {
} }
} }
#[derive(PartialEq, Clone)] #[derive(PartialEq, Clone, Debug)]
/// Information about a [`SynchronizedText`] /// Information about a [`SynchronizedText`]
pub struct SyncTextInformation { pub struct SyncTextInformation {
/// The text encoding (description/text) /// The text encoding (description/text)

View file

@ -53,7 +53,7 @@ where
} }
pub(crate) fn utf16_decode(reader: &[u8], endianness: fn([u8; 2]) -> u16) -> Result<String> { pub(crate) fn utf16_decode(reader: &[u8], endianness: fn([u8; 2]) -> u16) -> Result<String> {
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")); return Err(LoftyError::TextDecode("UTF-16 string has an odd length"));
} }

View file

@ -22,7 +22,7 @@ macro_rules! first_key {
// Keys should appear in order of popularity. // Keys should appear in order of popularity.
macro_rules! item_keys { macro_rules! item_keys {
(ALLOWED_UNKNOWN => [$($unknown_tag_type:pat),+]; $($variant:ident => [$($($tag_type:pat)|* => $($key:tt)|+),+]),+) => { (ALLOWED_UNKNOWN => [$($unknown_tag_type:pat),+]; $($variant:ident => [$($($tag_type:pat)|* => $($key:tt)|+),+]),+) => {
#[derive(PartialEq, Clone)] #[derive(PartialEq, Clone, Debug)]
#[allow(missing_docs)] #[allow(missing_docs)]
#[non_exhaustive] #[non_exhaustive]
/// A generic representation of a tag's key /// A generic representation of a tag's key

View file

@ -36,7 +36,7 @@ macro_rules! common_items {
} }
} }
#[derive(Clone)] #[derive(Clone, Debug)]
#[allow(clippy::struct_excessive_bools)] #[allow(clippy::struct_excessive_bools)]
/// **(ID3v2/APEv2 ONLY)** Various flags to describe the content of an item /// **(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) /// Represents a tag item (key/value)
pub struct TagItem { pub struct TagItem {
item_key: ItemKey, item_key: ItemKey,
@ -157,7 +157,7 @@ impl TagItem {
} }
} }
#[derive(Clone)] #[derive(Clone, Debug)]
/// Represents a tag item's value /// Represents a tag item's value
/// ///
/// NOTES: /// NOTES:
@ -288,6 +288,11 @@ impl Tag {
pub fn item_count(&self) -> u32 { pub fn item_count(&self) -> u32 {
self.items.len() as u32 self.items.len() as u32
} }
/// Returns the [`TagFlags`]
pub fn flags(&self) -> &TagFlags {
&self.flags
}
} }
impl Tag { impl Tag {