Skip to content

Upgrade to Rust 1.85 / Edition 2024 #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[workspace]
# TODO: Switch to MSRV-aware resolver version "3" (Rust 1.84)
resolver = "2"
resolver = "3"

members = [
"lofty",
@@ -11,8 +10,8 @@ members = [
]

[workspace.package]
edition = "2021"
rust-version = "1.82"
edition = "2024"
rust-version = "1.85"
repository = "https://github.com/Serial-ATA/lofty-rs"
license = "MIT OR Apache-2.0"

@@ -34,14 +33,6 @@ unused_import_braces = "deny"
explicit_outlives_requirements = "deny"
unknown_lints = "allow"

# Opt-in to new drop order of Edition 2024.
# TODO: Remove if no longer needed.
tail_expr_drop_order = "allow"
if_let_rescope = "allow"

# TODO: Remove after switching to Edition 2024.
edition_2024_expr_fragment_specifier = "allow"

[workspace.lints.clippy]
dbg_macro = "forbid"
string_to_string = "forbid"
2 changes: 1 addition & 1 deletion benches/create_tag.rs
Original file line number Diff line number Diff line change
@@ -67,8 +67,8 @@ bench_tag_write!([
);
}),
(id3v2, Id3v2Tag, |tag| {
use lofty::id3::v2::{Frame, TextInformationFrame};
use lofty::TextEncoding;
use lofty::id3::v2::{Frame, TextInformationFrame};

let picture = Picture::new_unchecked(
PictureType::CoverFront,
8 changes: 4 additions & 4 deletions lofty/src/aac/read.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::header::{ADTSHeader, HEADER_MASK};
use super::AacFile;
use super::header::{ADTSHeader, HEADER_MASK};
use crate::config::{ParseOptions, ParsingMode};
use crate::error::Result;
use crate::id3::v2::header::Id3v2Header;
use crate::id3::v2::read::parse_id3v2;
use crate::id3::{find_id3v1, ID3FindResults};
use crate::id3::{ID3FindResults, find_id3v1};
use crate::macros::{decode_err, err, parse_mode_choice};
use crate::mpeg::header::{cmp_header, search_for_frame_sync, HeaderCmpResult};
use crate::mpeg::header::{HeaderCmpResult, cmp_header, search_for_frame_sync};

use std::io::{Read, Seek, SeekFrom};

@@ -180,7 +180,7 @@ where
return Ok(Some((
first_header,
first_adts_frame_start_absolute + u64::from(header_len),
)))
)));
},
HeaderCmpResult::Undetermined => return Ok(None),
HeaderCmpResult::NotEqual => {},
2 changes: 1 addition & 1 deletion lofty/src/ape/mod.rs
Original file line number Diff line number Diff line change
@@ -20,8 +20,8 @@ use lofty_attr::LoftyFile;

pub use crate::picture::APE_PICTURE_TYPES;
pub use properties::ApeProperties;
pub use tag::item::ApeItem;
pub use tag::ApeTag;
pub use tag::item::ApeItem;

/// An APE file
#[derive(LoftyFile)]
2 changes: 1 addition & 1 deletion lofty/src/ape/read.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ use crate::error::Result;
use crate::id3::v1::tag::Id3v1Tag;
use crate::id3::v2::read::parse_id3v2;
use crate::id3::v2::tag::Id3v2Tag;
use crate::id3::{find_id3v1, find_id3v2, find_lyrics3v2, FindId3v2Config, ID3FindResults};
use crate::id3::{FindId3v2Config, ID3FindResults, find_id3v1, find_id3v2, find_lyrics3v2};
use crate::macros::{decode_err, err};

use std::io::{Read, Seek, SeekFrom};
4 changes: 2 additions & 2 deletions lofty/src/ape/tag/mod.rs
Original file line number Diff line number Diff line change
@@ -5,10 +5,10 @@ mod write;
use crate::ape::tag::item::{ApeItem, ApeItemRef};
use crate::config::WriteOptions;
use crate::error::{LoftyError, Result};
use crate::id3::v2::util::pairs::{format_number_pair, set_number, NUMBER_PAIR_KEYS};
use crate::id3::v2::util::pairs::{NUMBER_PAIR_KEYS, format_number_pair, set_number};
use crate::tag::item::ItemValueRef;
use crate::tag::{
try_parse_year, Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType,
Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType, try_parse_year,
};
use crate::util::flag_item;
use crate::util::io::{FileLike, Truncate};
4 changes: 2 additions & 2 deletions lofty/src/ape/tag/read.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::item::ApeItem;
use super::ApeTag;
use super::item::ApeItem;
use crate::ape::APE_PICTURE_TYPES;
use crate::ape::constants::{APE_PREAMBLE, INVALID_KEYS};
use crate::ape::header::{self, ApeHeader};
use crate::ape::APE_PICTURE_TYPES;
use crate::config::ParseOptions;
use crate::error::Result;
use crate::macros::{decode_err, err, try_vec};
6 changes: 3 additions & 3 deletions lofty/src/ape/tag/write.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::item::ApeItemRef;
use super::ApeTagRef;
use super::item::ApeItemRef;
use crate::ape::constants::APE_PREAMBLE;
use crate::ape::tag::read;
use crate::config::{ParseOptions, WriteOptions};
use crate::error::{LoftyError, Result};
use crate::id3::{find_id3v1, find_id3v2, find_lyrics3v2, FindId3v2Config};
use crate::id3::{FindId3v2Config, find_id3v1, find_id3v2, find_lyrics3v2};
use crate::macros::{decode_err, err};
use crate::probe::Probe;
use crate::tag::item::ItemValueRef;
@@ -134,7 +134,7 @@ where

// Now, if there was a tag at the beginning, remove it
if header_ape_tag.0 {
file_bytes.drain(header_ape_tag.1 .0 as usize..header_ape_tag.1 .1 as usize);
file_bytes.drain(header_ape_tag.1.0 as usize..header_ape_tag.1.1 as usize);
}

file.rewind()?;
10 changes: 5 additions & 5 deletions lofty/src/config/global_options.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ pub(crate) unsafe fn global_options() -> &'static GlobalOptions {
/// # Examples
///
/// ```rust
/// use lofty::config::{apply_global_options, GlobalOptions};
/// use lofty::config::{GlobalOptions, apply_global_options};
///
/// // I have a custom resolver that I need checked
/// let global_options = GlobalOptions::new().use_custom_resolvers(true);
@@ -58,7 +58,7 @@ impl GlobalOptions {
/// # Examples
///
/// ```rust
/// use lofty::config::{apply_global_options, GlobalOptions};
/// use lofty::config::{GlobalOptions, apply_global_options};
///
/// // By default, `use_custom_resolvers` is enabled. Here, we don't want to use them.
/// let global_options = GlobalOptions::new().use_custom_resolvers(false);
@@ -77,7 +77,7 @@ impl GlobalOptions {
/// # Examples
///
/// ```rust
/// use lofty::config::{apply_global_options, GlobalOptions};
/// use lofty::config::{GlobalOptions, apply_global_options};
///
/// // I have files with gigantic images, I'll double the allocation limit!
/// let global_options = GlobalOptions::new().allocation_limit(32 * 1024 * 1024);
@@ -100,7 +100,7 @@ impl GlobalOptions {
/// # Examples
///
/// ```rust
/// use lofty::config::{apply_global_options, GlobalOptions};
/// use lofty::config::{GlobalOptions, apply_global_options};
///
/// // I'm just reading tags, I don't need to preserve format-specific items
/// let global_options = GlobalOptions::new().preserve_format_specific_items(false);
@@ -136,7 +136,7 @@ impl Default for GlobalOptions {
/// # Examples
///
/// ```rust
/// use lofty::config::{apply_global_options, GlobalOptions};
/// use lofty::config::{GlobalOptions, apply_global_options};
///
/// // I have a custom resolver that I need checked
/// let global_options = GlobalOptions::new().use_custom_resolvers(true);
2 changes: 1 addition & 1 deletion lofty/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ mod global_options;
mod parse_options;
mod write_options;

pub use global_options::{apply_global_options, GlobalOptions};
pub use global_options::{GlobalOptions, apply_global_options};
pub use parse_options::{ParseOptions, ParsingMode};
pub use write_options::WriteOptions;

4 changes: 2 additions & 2 deletions lofty/src/flac/read.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::FlacFile;
use super::block::Block;
use super::properties::FlacProperties;
use super::FlacFile;
use crate::config::{ParseOptions, ParsingMode};
use crate::error::Result;
use crate::flac::block::{BLOCK_ID_PICTURE, BLOCK_ID_STREAMINFO, BLOCK_ID_VORBIS_COMMENTS};
use crate::id3::v2::read::parse_id3v2;
use crate::id3::{find_id3v2, FindId3v2Config, ID3FindResults};
use crate::id3::{FindId3v2Config, ID3FindResults, find_id3v2};
use crate::macros::{decode_err, err};
use crate::ogg::read::read_comments;
use crate::picture::Picture;
2 changes: 1 addition & 1 deletion lofty/src/flac/write.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::block::{Block, BLOCK_ID_PADDING, BLOCK_ID_PICTURE, BLOCK_ID_VORBIS_COMMENTS};
use super::block::{BLOCK_ID_PADDING, BLOCK_ID_PICTURE, BLOCK_ID_VORBIS_COMMENTS, Block};
use super::read::verify_flac;
use crate::config::WriteOptions;
use crate::error::{LoftyError, Result};
6 changes: 1 addition & 5 deletions lofty/src/id3/v1/read.rs
Original file line number Diff line number Diff line change
@@ -46,9 +46,5 @@ fn decode_text(data: &[u8]) -> Option<String> {
.map(|c| *c as char)
.collect::<String>();

if read.is_empty() {
None
} else {
Some(read)
}
if read.is_empty() { None } else { Some(read) }
}
2 changes: 1 addition & 1 deletion lofty/src/id3/v1/write.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::tag::Id3v1TagRef;
use crate::config::WriteOptions;
use crate::error::{LoftyError, Result};
use crate::id3::{find_id3v1, ID3FindResults};
use crate::id3::{ID3FindResults, find_id3v1};
use crate::macros::err;
use crate::probe::Probe;
use crate::util::io::{FileLike, Length, Truncate};
6 changes: 3 additions & 3 deletions lofty/src/id3/v2/frame/conversion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::TextEncoding;
use crate::error::{Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
use crate::id3::v2::frame::{FrameRef, EMPTY_CONTENT_DESCRIPTOR, MUSICBRAINZ_UFID_OWNER};
use crate::id3::v2::frame::{EMPTY_CONTENT_DESCRIPTOR, FrameRef, MUSICBRAINZ_UFID_OWNER};
use crate::id3::v2::tag::{
new_binary_frame, new_comment_frame, new_text_frame, new_unsync_text_frame, new_url_frame,
new_user_text_frame, new_user_url_frame,
@@ -10,7 +11,6 @@ use crate::id3::v2::{
};
use crate::macros::err;
use crate::tag::{ItemKey, ItemValue, TagItem, TagType};
use crate::TextEncoding;

use std::borrow::Cow;

@@ -132,7 +132,7 @@ impl<'a> TryFrom<&'a TagItem> for FrameRef<'a> {
return Err(Id3v2Error::new(Id3v2ErrorKind::UnsupportedFrameId(
item_key.clone(),
))
.into())
.into());
},
}
},
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/frame/header/parse.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::FrameFlags;
use crate::error::{Id3v2Error, Id3v2ErrorKind, Result};
use crate::id3::v2::FrameId;
use crate::id3::v2::util::synchsafe::SynchsafeInteger;
use crate::id3::v2::util::upgrade::{upgrade_v2, upgrade_v3};
use crate::id3::v2::FrameId;
use crate::util::text::utf8_decode_str;

use crate::config::ParseOptions;
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/frame/read.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::header::parse::{parse_header, parse_v2_header};
use super::Frame;
use super::header::parse::{parse_header, parse_v2_header};
use crate::config::{ParseOptions, ParsingMode};
use crate::error::{Id3v2Error, Id3v2ErrorKind, Result};
use crate::id3::v2::frame::content::parse_content;
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/header.rs
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ impl Id3v2Header {
major => {
return Err(
Id3v2Error::new(Id3v2ErrorKind::BadId3v2Version(major, header[4])).into(),
)
);
},
};

4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/attached_picture_frame.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use crate::id3::v2::header::Id3v2Version;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::macros::err;
use crate::picture::{MimeType, Picture, PictureType};
use crate::util::text::{encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, encode_text};

use std::borrow::Cow;
use std::io::{Read, Write as _};
@@ -82,7 +82,7 @@ impl AttachedPictureFrame<'_> {
return Err(Id3v2Error::new(Id3v2ErrorKind::BadPictureFormat(
String::from_utf8_lossy(&format).into_owned(),
))
.into())
.into());
},
}
} else {
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/audio_text_frame.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::error::{ErrorKind, Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::borrow::Cow;
use std::hash::{Hash, Hasher};
@@ -234,8 +234,8 @@ pub fn scramble(audio_data: &mut [u8]) {

#[cfg(test)]
mod tests {
use crate::id3::v2::{AudioTextFrame, AudioTextFrameFlags, FrameFlags};
use crate::TextEncoding;
use crate::id3::v2::{AudioTextFrame, AudioTextFrameFlags, FrameFlags};

fn expected() -> AudioTextFrame<'static> {
AudioTextFrame {
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/encapsulated_object.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::error::{ErrorKind, Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::io::{Cursor, Read};

2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/extended_text_frame.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ use crate::id3::v2::header::Id3v2Version;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::macros::err;
use crate::util::text::{
decode_text, encode_text, utf16_decode_bytes, TextDecodeOptions, TextEncoding,
TextDecodeOptions, TextEncoding, decode_text, encode_text, utf16_decode_bytes,
};

use std::borrow::Cow;
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/extended_url_frame.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use crate::error::Result;
use crate::id3::v2::frame::content::verify_encoding;
use crate::id3::v2::header::Id3v2Version;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::borrow::Cow;
use std::hash::{Hash, Hasher};
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/key_value_frame.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use crate::error::Result;
use crate::id3::v2::frame::content::verify_encoding;
use crate::id3::v2::header::Id3v2Version;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use byteorder::ReadBytesExt;

2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/language_frame.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use crate::id3::v2::frame::content::verify_encoding;
use crate::id3::v2::header::Id3v2Version;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::tag::items::Lang;
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::borrow::Cow;
use std::hash::{Hash, Hasher};
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/mod.rs
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ mod unique_file_identifier;
mod url_link_frame;

pub use attached_picture_frame::AttachedPictureFrame;
pub use audio_text_frame::{scramble, AudioTextFrame, AudioTextFrameFlags};
pub use audio_text_frame::{AudioTextFrame, AudioTextFrameFlags, scramble};
pub use binary_frame::BinaryFrame;
pub use encapsulated_object::GeneralEncapsulatedObject;
pub use event_timing_codes_frame::{Event, EventTimingCodesFrame, EventType};
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/ownership_frame.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::error::{ErrorKind, Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{
decode_text, encode_text, utf8_decode_str, TextDecodeOptions, TextEncoding,
TextDecodeOptions, TextEncoding, decode_text, encode_text, utf8_decode_str,
};

use std::borrow::Cow;
@@ -138,8 +138,8 @@ impl OwnershipFrame<'_> {

#[cfg(test)]
mod tests {
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId, OwnershipFrame};
use crate::TextEncoding;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId, OwnershipFrame};

use std::borrow::Cow;

2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/popularimeter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::error::Result;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::alloc::VecFallibleCapacity;
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::borrow::Cow;
use std::hash::{Hash, Hasher};
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/private_frame.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::error::Result;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::alloc::VecFallibleCapacity;
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::borrow::Cow;
use std::io::Read;
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/relative_volume_adjustment_frame.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use crate::config::ParsingMode;
use crate::error::{Id3v2Error, Id3v2ErrorKind, Result};
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::macros::try_vec;
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::borrow::Cow;
use std::collections::HashMap;
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/items/sync_text.rs
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ use crate::error::{ErrorKind, Id3v2Error, Id3v2ErrorKind, LoftyError, Result};
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::macros::err;
use crate::util::text::{
decode_text, encode_text, read_to_terminator, utf16_decode_bytes, TextDecodeOptions,
TextEncoding,
TextDecodeOptions, TextEncoding, decode_text, encode_text, read_to_terminator,
utf16_decode_bytes,
};

use std::borrow::Cow;
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/text_information_frame.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use crate::error::Result;
use crate::id3::v2::frame::content::verify_encoding;
use crate::id3::v2::header::Id3v2Version;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use byteorder::ReadBytesExt;

2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/timestamp_frame.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use crate::error::Result;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::macros::err;
use crate::tag::items::Timestamp;
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::io::Read;

30 changes: 17 additions & 13 deletions lofty/src/id3/v2/items/unique_file_identifier.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use crate::config::ParsingMode;
use crate::error::{Id3v2Error, Id3v2ErrorKind, Result};
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::macros::parse_mode_choice;
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::borrow::Cow;
use std::hash::{Hash, Hasher};
@@ -134,17 +134,21 @@ mod tests {

let bytes = ufid_no_owner.as_bytes();

assert!(UniqueFileIdentifierFrame::parse(
&mut &bytes[..],
FrameFlags::default(),
ParsingMode::Strict
)
.is_err());
assert!(UniqueFileIdentifierFrame::parse(
&mut &bytes[..],
FrameFlags::default(),
ParsingMode::BestAttempt
)
.is_ok());
assert!(
UniqueFileIdentifierFrame::parse(
&mut &bytes[..],
FrameFlags::default(),
ParsingMode::Strict
)
.is_err()
);
assert!(
UniqueFileIdentifierFrame::parse(
&mut &bytes[..],
FrameFlags::default(),
ParsingMode::BestAttempt
)
.is_ok()
);
}
}
2 changes: 1 addition & 1 deletion lofty/src/id3/v2/items/url_link_frame.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::error::Result;
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
use crate::util::text::{decode_text, encode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text, encode_text};

use std::hash::Hash;
use std::io::Read;
14 changes: 8 additions & 6 deletions lofty/src/id3/v2/read.rs
Original file line number Diff line number Diff line change
@@ -191,12 +191,14 @@ mod tests {

let mut f = Cursor::new(std::fs::read("tests/tags/assets/id3v2/zero.id3v2").unwrap());
let header = Id3v2Header::parse(&mut f).unwrap();
assert!(parse_id3v2(
&mut f,
header,
ParseOptions::new().parsing_mode(ParsingMode::Strict)
)
.is_ok());
assert!(
parse_id3v2(
&mut f,
header,
ParseOptions::new().parsing_mode(ParsingMode::Strict)
)
.is_ok()
);
}

#[test_log::test]
10 changes: 5 additions & 5 deletions lofty/src/id3/v2/tag.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[cfg(test)]
mod tests;

use super::frame::{Frame, EMPTY_CONTENT_DESCRIPTOR};
use super::frame::{EMPTY_CONTENT_DESCRIPTOR, Frame};
use super::header::{Id3v2TagFlags, Id3v2Version};
use crate::config::{global_options, WriteOptions};
use crate::config::{WriteOptions, global_options};
use crate::error::{LoftyError, Result};
use crate::id3::v1::GENRES;
use crate::id3::v2::frame::{FrameRef, MUSICBRAINZ_UFID_OWNER};
@@ -13,7 +13,7 @@ use crate::id3::v2::items::{
};
use crate::id3::v2::util::mappings::TIPL_MAPPINGS;
use crate::id3::v2::util::pairs::{
format_number_pair, set_number, NUMBER_PAIR_KEYS, NUMBER_PAIR_SEPARATOR,
NUMBER_PAIR_KEYS, NUMBER_PAIR_SEPARATOR, format_number_pair, set_number,
};
use crate::id3::v2::{BinaryFrame, FrameHeader, FrameId, KeyValueFrame, TimestampFrame};
use crate::mp4::AdvisoryRating;
@@ -23,7 +23,7 @@ use crate::tag::items::{Lang, Timestamp, UNKNOWN_LANGUAGE};
use crate::tag::{Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType};
use crate::util::flag_item;
use crate::util::io::{FileLike, Length, Truncate};
use crate::util::text::{decode_text, TextDecodeOptions, TextEncoding};
use crate::util::text::{TextDecodeOptions, TextEncoding, decode_text};

use std::borrow::Cow;
use std::io::{Cursor, Write};
@@ -395,9 +395,9 @@ impl Id3v2Tag {
/// # Examples
///
/// ```rust
/// use lofty::TextEncoding;
/// use lofty::id3::v2::{Frame, FrameFlags, FrameId, Id3v2Tag, TextInformationFrame};
/// use lofty::tag::TagExt;
/// use lofty::TextEncoding;
/// use std::borrow::Cow;
///
/// const MOOD_FRAME_ID: FrameId<'static> = FrameId::Valid(Cow::Borrowed("TMOO"));
79 changes: 46 additions & 33 deletions lofty/src/id3/v2/tag/tests.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ use crate::id3::v2::{
ChannelInformation, ChannelType, RelativeVolumeAdjustmentFrame, TimestampFrame,
};
use crate::picture::MimeType;
use crate::tag::items::{Timestamp, ENGLISH};
use crate::tag::items::{ENGLISH, Timestamp};
use crate::tag::utils::test_utils::read_path;

use super::*;
@@ -499,11 +499,12 @@ fn comments() {
assert_eq!(Some(Cow::Borrowed("")), tag.comment());

// Insert a custom comment frame
assert!(tag
.frames
.iter()
.find_map(|frame| filter_comment_frame_by_description(frame, custom_descriptor))
.is_none());
assert!(
tag.frames
.iter()
.find_map(|frame| filter_comment_frame_by_description(frame, custom_descriptor))
.is_none()
);
tag.insert(Frame::Comment(CommentFrame::new(
encoding,
*b"eng",
@@ -518,11 +519,12 @@ fn comments() {
assert!(tag.comment().is_none());

// Verify that the comment with the custom descriptor still exists
assert!(tag
.frames
.iter()
.find_map(|frame| filter_comment_frame_by_description(frame, custom_descriptor))
.is_some());
assert!(
tag.frames
.iter()
.find_map(|frame| filter_comment_frame_by_description(frame, custom_descriptor))
.is_some()
);
}

#[test_log::test]
@@ -557,10 +559,12 @@ fn txxx_wxxx_tag_conversion() {
ItemValue::Locator(String::from("bar url")),
),
];
assert!(expected_items
.iter()
.zip(tag.items())
.all(|(expected, actual)| expected == actual));
assert!(
expected_items
.iter()
.zip(tag.items())
.all(|(expected, actual)| expected == actual)
);

let tag: Id3v2Tag = tag.into();

@@ -915,15 +919,18 @@ fn ufid_frame_with_musicbrainz_record_id() {
let id3v2 = split_remainder.merge_tag(split_tag);
assert_eq!(2, id3v2.len());
match &id3v2.frames[..] {
[Frame::UniqueFileIdentifier(UniqueFileIdentifierFrame {
owner: first_owner,
identifier: first_identifier,
..
}), Frame::UniqueFileIdentifier(UniqueFileIdentifierFrame {
owner: second_owner,
identifier: second_identifier,
..
})] => {
[
Frame::UniqueFileIdentifier(UniqueFileIdentifierFrame {
owner: first_owner,
identifier: first_identifier,
..
}),
Frame::UniqueFileIdentifier(UniqueFileIdentifierFrame {
owner: second_owner,
identifier: second_identifier,
..
}),
] => {
assert_eq!(&unknown_ufid_frame.owner, first_owner);
assert_eq!(&unknown_ufid_frame.identifier, first_identifier);
assert_eq!(&musicbrainz_recording_id_frame.owner, second_owner);
@@ -961,22 +968,28 @@ fn get_set_user_defined_text() {
id3v2.insert(txxx_frame2);

// We cannot get user defined texts through `get_text`
assert!(id3v2
.get_text(&FrameId::Valid(Cow::Borrowed("TXXX")))
.is_none());
assert!(
id3v2
.get_text(&FrameId::Valid(Cow::Borrowed("TXXX")))
.is_none()
);

assert_eq!(id3v2.get_user_text(description.as_str()), Some(&*content));

// Wipe the tag
id3v2.clear();

// Same thing process as above, using simplified setter
assert!(id3v2
.insert_user_text(description.clone(), content.clone())
.is_none());
assert!(id3v2
.insert_user_text(description2.clone(), content2.clone())
.is_none());
assert!(
id3v2
.insert_user_text(description.clone(), content.clone())
.is_none()
);
assert!(
id3v2
.insert_user_text(description2.clone(), content2.clone())
.is_none()
);
assert_eq!(id3v2.get_user_text(description.as_str()), Some(&*content));

// Remove one frame
4 changes: 2 additions & 2 deletions lofty/src/id3/v2/write/mod.rs
Original file line number Diff line number Diff line change
@@ -5,11 +5,11 @@ use super::Id3v2TagFlags;
use crate::config::WriteOptions;
use crate::error::{LoftyError, Result};
use crate::file::FileType;
use crate::id3::v2::Id3v2Tag;
use crate::id3::v2::frame::FrameRef;
use crate::id3::v2::tag::Id3v2TagRef;
use crate::id3::v2::util::synchsafe::SynchsafeInteger;
use crate::id3::v2::Id3v2Tag;
use crate::id3::{find_id3v2, FindId3v2Config};
use crate::id3::{FindId3v2Config, find_id3v2};
use crate::macros::{err, try_vec};
use crate::probe::Probe;
use crate::util::io::{FileLike, Length, Truncate};
2 changes: 1 addition & 1 deletion lofty/src/iff/aiff/read.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::AiffFile;
use super::properties::AiffProperties;
use super::tag::{AiffTextChunks, Comment};
use super::AiffFile;
use crate::config::ParseOptions;
use crate::error::Result;
use crate::id3::v2::tag::Id3v2Tag;
2 changes: 1 addition & 1 deletion lofty/src/iff/wav/read.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::WavFile;
use super::properties::WavProperties;
use super::tag::RiffInfoList;
use super::WavFile;
use crate::config::ParseOptions;
use crate::error::Result;
use crate::id3::v2::tag::Id3v2Tag;
2 changes: 1 addition & 1 deletion lofty/src/iff/wav/tag/mod.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ mod write;
use crate::config::WriteOptions;
use crate::error::{LoftyError, Result};
use crate::tag::{
try_parse_year, Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType,
Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType, try_parse_year,
};
use crate::util::io::{FileLike, Length, Truncate};

4 changes: 1 addition & 3 deletions lofty/src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
macro_rules! try_vec {
($elem:expr; $size:expr) => {{
$crate::util::alloc::fallible_vec_from_element($elem, $size)?
}};
($elem:expr; $size:expr) => {{ $crate::util::alloc::fallible_vec_from_element($elem, $size)? }};
}

// Shorthand for return Err(LoftyError::new(ErrorKind::Foo))
2 changes: 1 addition & 1 deletion lofty/src/mp4/ilst/atom.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::error::Result;
use crate::macros::err;
use crate::mp4::ilst::data_type::DataType;
use crate::mp4::AtomIdent;
use crate::mp4::ilst::data_type::DataType;
use crate::picture::Picture;

use std::fmt::{Debug, Formatter};
20 changes: 11 additions & 9 deletions lofty/src/mp4/ilst/mod.rs
Original file line number Diff line number Diff line change
@@ -7,13 +7,13 @@ mod r#ref;
pub(crate) mod write;

use super::AtomIdent;
use crate::config::{global_options, WriteOptions};
use crate::config::{WriteOptions, global_options};
use crate::error::LoftyError;
use crate::mp4::ilst::atom::AtomDataStorage;
use crate::picture::{Picture, PictureType, TOMBSTONE_PICTURE};
use crate::tag::companion_tag::CompanionTag;
use crate::tag::{
try_parse_year, Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType,
Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType, try_parse_year,
};
use crate::util::flag_item;
use crate::util::io::{FileLike, Length, Truncate};
@@ -459,7 +459,7 @@ impl Ilst {
return Some(u16::from_be_bytes([
data[expected_size - 2],
data[expected_size - 1],
]))
]));
},
_ => {},
}
@@ -883,8 +883,8 @@ impl From<Tag> for Ilst {
#[cfg(test)]
mod tests {
use crate::config::{ParseOptions, ParsingMode, WriteOptions};
use crate::mp4::ilst::atom::AtomDataStorage;
use crate::mp4::ilst::TITLE;
use crate::mp4::ilst::atom::AtomDataStorage;
use crate::mp4::read::AtomReader;
use crate::mp4::{AdvisoryRating, Atom, AtomData, AtomIdent, DataType, Ilst, Mp4File};
use crate::picture::{MimeType, Picture, PictureType};
@@ -1136,11 +1136,13 @@ mod tests {
const PADDING_SIZE: usize = 990;

let file_bytes = read_path("tests/files/assets/ilst_trailing_padding.m4a");
assert!(Mp4File::read_from(
&mut Cursor::new(&file_bytes),
ParseOptions::new().read_properties(false)
)
.is_ok());
assert!(
Mp4File::read_from(
&mut Cursor::new(&file_bytes),
ParseOptions::new().read_properties(false)
)
.is_ok()
);

let mut ilst;
let old_free_size;
6 changes: 3 additions & 3 deletions lofty/src/mp4/ilst/read.rs
Original file line number Diff line number Diff line change
@@ -5,12 +5,12 @@ use crate::config::{ParseOptions, ParsingMode};
use crate::error::{LoftyError, Result};
use crate::id3::v1::constants::GENRES;
use crate::macros::{err, try_vec};
use crate::mp4::atom_info::{AtomInfo, ATOM_HEADER_LEN};
use crate::mp4::atom_info::{ATOM_HEADER_LEN, AtomInfo};
use crate::mp4::ilst::atom::AtomDataStorage;
use crate::mp4::read::{skip_atom, AtomReader};
use crate::mp4::read::{AtomReader, skip_atom};
use crate::picture::{MimeType, Picture, PictureType};
use crate::tag::TagExt;
use crate::util::text::{utf16_decode_bytes, utf8_decode};
use crate::util::text::{utf8_decode, utf16_decode_bytes};

use std::borrow::Cow;
use std::io::{Cursor, Read, Seek, SeekFrom};
6 changes: 3 additions & 3 deletions lofty/src/mp4/ilst/write.rs
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@ use crate::config::{ParseOptions, WriteOptions};
use crate::error::{FileEncodingError, LoftyError, Result};
use crate::file::FileType;
use crate::macros::{decode_err, err, try_vec};
use crate::mp4::atom_info::{AtomIdent, AtomInfo, ATOM_HEADER_LEN, FOURCC_LEN};
use crate::mp4::AtomData;
use crate::mp4::atom_info::{ATOM_HEADER_LEN, AtomIdent, AtomInfo, FOURCC_LEN};
use crate::mp4::ilst::r#ref::AtomRef;
use crate::mp4::read::{atom_tree, find_child_atom, meta_is_full, verify_mp4, AtomReader};
use crate::mp4::read::{AtomReader, atom_tree, find_child_atom, meta_is_full, verify_mp4};
use crate::mp4::write::{AtomWriter, AtomWriterCompanion, ContextualAtom};
use crate::mp4::AtomData;
use crate::picture::{MimeType, Picture};
use crate::util::alloc::VecFallibleCapacity;
use crate::util::io::{FileLike, Length, Truncate};
2 changes: 1 addition & 1 deletion lofty/src/mp4/mod.rs
Original file line number Diff line number Diff line change
@@ -23,10 +23,10 @@ pub mod constants {

pub use crate::mp4::properties::{AudioObjectType, Mp4Codec, Mp4Properties};
pub use atom_info::AtomIdent;
pub use ilst::Ilst;
pub use ilst::advisory_rating::AdvisoryRating;
pub use ilst::atom::{Atom, AtomData};
pub use ilst::data_type::DataType;
pub use ilst::Ilst;

pub(crate) use properties::SAMPLE_RATES;

4 changes: 2 additions & 2 deletions lofty/src/mp4/moov.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::atom_info::{AtomIdent, AtomInfo};
use super::ilst::read::parse_ilst;
use super::ilst::Ilst;
use super::read::{find_child_atom, meta_is_full, skip_atom, AtomReader};
use super::ilst::read::parse_ilst;
use super::read::{AtomReader, find_child_atom, meta_is_full, skip_atom};
use crate::config::ParseOptions;
use crate::error::Result;
use crate::macros::decode_err;
2 changes: 1 addition & 1 deletion lofty/src/mp4/properties.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::atom_info::{AtomIdent, AtomInfo};
use super::read::{find_child_atom, skip_atom, AtomReader};
use super::read::{AtomReader, find_child_atom, skip_atom};
use crate::config::ParsingMode;
use crate::error::{LoftyError, Result};
use crate::macros::{decode_err, err, try_vec};
2 changes: 1 addition & 1 deletion lofty/src/mp4/read/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
mod atom_reader;

use super::Mp4File;
use super::atom_info::{AtomIdent, AtomInfo};
use super::moov::Moov;
use super::properties::Mp4Properties;
use super::Mp4File;
use crate::config::{ParseOptions, ParsingMode};
use crate::error::{ErrorKind, LoftyError, Result};
use crate::macros::{decode_err, err};
2 changes: 1 addition & 1 deletion lofty/src/mpeg/header.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::constants::{BITRATES, PADDING_SIZES, SAMPLES, SAMPLE_RATES, SIDE_INFORMATION_SIZES};
use super::constants::{BITRATES, PADDING_SIZES, SAMPLE_RATES, SAMPLES, SIDE_INFORMATION_SIZES};
use crate::error::Result;
use crate::macros::decode_err;

6 changes: 3 additions & 3 deletions lofty/src/mpeg/read.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::header::{cmp_header, search_for_frame_sync, Header, HeaderCmpResult, VbrHeader};
use super::header::{Header, HeaderCmpResult, VbrHeader, cmp_header, search_for_frame_sync};
use super::{MpegFile, MpegProperties};
use crate::ape::header::read_ape_header;
use crate::config::{ParseOptions, ParsingMode};
use crate::error::Result;
use crate::id3::v2::header::Id3v2Header;
use crate::id3::v2::read::parse_id3v2;
use crate::id3::{find_id3v1, find_lyrics3v2, FindId3v2Config, ID3FindResults};
use crate::id3::{FindId3v2Config, ID3FindResults, find_id3v1, find_lyrics3v2};
use crate::io::SeekStreamLen;
use crate::macros::{decode_err, err};
use crate::mpeg::header::HEADER_MASK;
@@ -231,7 +231,7 @@ where
if let Some(first_header) = Header::read(first_header_data) {
match cmp_header(reader, 4, first_header.len, first_header_data, HEADER_MASK) {
HeaderCmpResult::Equal => {
return Ok(Some((first_header, first_mp3_frame_start_absolute)))
return Ok(Some((first_header, first_mp3_frame_start_absolute)));
},
HeaderCmpResult::Undetermined => return Ok(None),
HeaderCmpResult::NotEqual => {},
2 changes: 1 addition & 1 deletion lofty/src/musepack/read.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ use super::{MpcFile, MpcProperties, MpcStreamVersion};
use crate::config::ParseOptions;
use crate::error::Result;
use crate::id3::v2::read::parse_id3v2;
use crate::id3::{find_id3v1, find_id3v2, find_lyrics3v2, FindId3v2Config, ID3FindResults};
use crate::id3::{FindId3v2Config, ID3FindResults, find_id3v1, find_id3v2, find_lyrics3v2};
use crate::macros::err;
use crate::util::io::SeekStreamLen;

6 changes: 3 additions & 3 deletions lofty/src/ogg/mod.rs
Original file line number Diff line number Diff line change
@@ -21,14 +21,14 @@ use ogg_pager::{Page, PageHeader};

// Exports

pub use opus::properties::OpusProperties;
pub use opus::OpusFile;
pub use opus::properties::OpusProperties;
pub use picture_storage::OggPictureStorage;
pub use speex::properties::SpeexProperties;
pub use speex::SpeexFile;
pub use speex::properties::SpeexProperties;
pub use tag::VorbisComments;
pub use vorbis::properties::VorbisProperties;
pub use vorbis::VorbisFile;
pub use vorbis::properties::VorbisProperties;

fn verify_signature(content: &[u8], sig: &[u8]) -> Result<()> {
let sig_len = sig.len();
2 changes: 1 addition & 1 deletion lofty/src/ogg/read.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ use crate::error::{ErrorKind, LoftyError, Result};
use crate::macros::{decode_err, err, parse_mode_choice};
use crate::picture::{MimeType, Picture, PictureInformation, PictureType};
use crate::tag::Accessor;
use crate::util::text::{utf16_decode, utf8_decode, utf8_decode_str};
use crate::util::text::{utf8_decode, utf8_decode_str, utf16_decode};

use std::borrow::Cow;
use std::io::{Read, Seek, SeekFrom};
2 changes: 1 addition & 1 deletion lofty/src/ogg/tag.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ use crate::ogg::write::OGGFormat;
use crate::picture::{Picture, PictureInformation};
use crate::probe::Probe;
use crate::tag::{
try_parse_year, Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType,
Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType, try_parse_year,
};
use crate::util::flag_item;
use crate::util::io::{FileLike, Length, Truncate};
4 changes: 2 additions & 2 deletions lofty/src/ogg/write.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ use crate::error::{LoftyError, Result};
use crate::file::FileType;
use crate::macros::{decode_err, err, try_vec};
use crate::ogg::constants::{OPUSTAGS, VORBIS_COMMENT_HEAD};
use crate::ogg::tag::{create_vorbis_comments_ref, VorbisCommentsRef};
use crate::ogg::tag::{VorbisCommentsRef, create_vorbis_comments_ref};
use crate::picture::{Picture, PictureInformation};
use crate::tag::{Tag, TagType};
use crate::util::io::{FileLike, Length, Truncate};
@@ -13,7 +13,7 @@ use std::borrow::Cow;
use std::io::{Cursor, Read, Seek, SeekFrom, Write};

use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use ogg_pager::{Packets, Page, PageHeader, CONTAINS_FIRST_PAGE_OF_BITSTREAM};
use ogg_pager::{CONTAINS_FIRST_PAGE_OF_BITSTREAM, Packets, Page, PageHeader};

#[derive(PartialEq, Copy, Clone)]
pub(crate) enum OGGFormat {
4 changes: 2 additions & 2 deletions lofty/src/probe.rs
Original file line number Diff line number Diff line change
@@ -2,16 +2,16 @@
use crate::aac::AacFile;
use crate::ape::ApeFile;
use crate::config::{global_options, ParseOptions};
use crate::config::{ParseOptions, global_options};
use crate::error::Result;
use crate::file::{AudioFile, FileType, FileTypeGuessResult, TaggedFile};
use crate::flac::FlacFile;
use crate::iff::aiff::AiffFile;
use crate::iff::wav::WavFile;
use crate::macros::err;
use crate::mp4::Mp4File;
use crate::mpeg::header::search_for_frame_sync;
use crate::mpeg::MpegFile;
use crate::mpeg::header::search_for_frame_sync;
use crate::musepack::MpcFile;
use crate::ogg::opus::OpusFile;
use crate::ogg::speex::SpeexFile;
2 changes: 1 addition & 1 deletion lofty/src/resolve.rs
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ mod tests {
use crate::file::{FileType, TaggedFileExt};
use crate::id3::v2::Id3v2Tag;
use crate::properties::FileProperties;
use crate::resolve::{register_custom_resolver, FileResolver};
use crate::resolve::{FileResolver, register_custom_resolver};
use crate::tag::{Accessor, TagType};

use std::fs::File;
2 changes: 1 addition & 1 deletion lofty/src/tag/item.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::tag::items::{Lang, UNKNOWN_LANGUAGE};
use crate::tag::TagType;
use crate::tag::items::{Lang, UNKNOWN_LANGUAGE};

use std::borrow::Cow;
use std::collections::HashMap;
2 changes: 1 addition & 1 deletion lofty/src/tag/mod.rs
Original file line number Diff line number Diff line change
@@ -333,7 +333,7 @@ impl Tag {
if let Some(item) = self.get(item_key) {
match item.value() {
ItemValue::Text(text) | ItemValue::Locator(text) if convert => {
return Some(text.as_bytes())
return Some(text.as_bytes());
},
ItemValue::Binary(binary) => return Some(binary),
_ => {},
2 changes: 1 addition & 1 deletion lofty/src/tag/tag_type.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{utils, Tag};
use super::{Tag, utils};
use crate::config::WriteOptions;
use crate::error::LoftyError;
use crate::file::FileType;
2 changes: 1 addition & 1 deletion lofty/src/tag/utils.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ use crate::id3::v1::tag::Id3v1TagRef;
use crate::id3::v2::tag::Id3v2TagRef;
use crate::id3::v2::{self, Id3v2TagFlags};
use crate::mp4::Ilst;
use crate::ogg::tag::{create_vorbis_comments_ref, VorbisCommentsRef};
use crate::ogg::tag::{VorbisCommentsRef, create_vorbis_comments_ref};
use ape::tag::ApeTagRef;
use iff::aiff::tag::AiffTextChunksRef;
use iff::wav::tag::RIFFInfoListRef;
12 changes: 9 additions & 3 deletions lofty/src/util/text.rs
Original file line number Diff line number Diff line change
@@ -393,7 +393,9 @@ mod tests {

assert_eq!(
utf16_encode.as_slice(),
&[0xFE, 0xFF, 0x00, 0x6C, 0x00, 0xF8, 0x00, 0x66, 0x00, 0x74, 0x00, 0xA5]
&[
0xFE, 0xFF, 0x00, 0x6C, 0x00, 0xF8, 0x00, 0x66, 0x00, 0x74, 0x00, 0xA5
]
);

// BOM test
@@ -409,11 +411,15 @@ mod tests {
);
assert_eq!(
le_utf16_encode.as_slice(),
&[0xFF, 0xFE, 0x6C, 0x00, 0xF8, 0x00, 0x66, 0x00, 0x74, 0x00, 0xA5, 0x00]
&[
0xFF, 0xFE, 0x6C, 0x00, 0xF8, 0x00, 0x66, 0x00, 0x74, 0x00, 0xA5, 0x00
]
);
assert_eq!(
be_utf16_encode_bom.as_slice(),
&[0xFE, 0xFF, 0x00, 0x6C, 0x00, 0xF8, 0x00, 0x66, 0x00, 0x74, 0x00, 0xA5]
&[
0xFE, 0xFF, 0x00, 0x6C, 0x00, 0xF8, 0x00, 0x66, 0x00, 0x74, 0x00, 0xA5
]
);

let utf8_encode = super::encode_text(TEST_STRING, TextEncoding::UTF8, false);
4 changes: 2 additions & 2 deletions lofty/src/wavpack/read.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::properties::WavPackProperties;
use super::WavPackFile;
use super::properties::WavPackProperties;
use crate::config::ParseOptions;
use crate::error::Result;
use crate::id3::{find_id3v1, find_lyrics3v2, ID3FindResults};
use crate::id3::{ID3FindResults, find_id3v1, find_lyrics3v2};

use crate::macros::err;
use std::io::{Read, Seek, SeekFrom};
16 changes: 9 additions & 7 deletions lofty/tests/files/flac.rs
Original file line number Diff line number Diff line change
@@ -14,13 +14,15 @@ fn multiple_vorbis_comments() {

// Reading a file with multiple VORBIS_COMMENT blocks should error when using `Strict`, as it is
// not allowed by spec.
assert!(FlacFile::read_from(
&mut file,
ParseOptions::new()
.read_properties(false)
.parsing_mode(ParsingMode::Strict)
)
.is_err());
assert!(
FlacFile::read_from(
&mut file,
ParseOptions::new()
.read_properties(false)
.parsing_mode(ParsingMode::Strict)
)
.is_err()
);

file.rewind().unwrap();

7 changes: 4 additions & 3 deletions lofty/tests/files/ogg.rs
Original file line number Diff line number Diff line change
@@ -207,12 +207,13 @@ fn flac_try_write_non_empty_id3v2() {
let mut tag = Id3v2Tag::default();
tag.set_artist(String::from("Foo artist"));

assert!(tag
.save_to_path(
assert!(
tag.save_to_path(
"tests/files/assets/flac_with_id3v2.flac",
WriteOptions::default()
)
.is_err());
.is_err()
);
}

#[test_log::test]
2 changes: 1 addition & 1 deletion lofty/tests/picture/format_parsers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use lofty::TextEncoding;
use lofty::config::ParsingMode;
use lofty::id3::v2::{AttachedPictureFrame, FrameFlags, Id3v2Version};
use lofty::picture::{Picture, PictureInformation, PictureType};
use lofty::TextEncoding;

use std::fs::File;
use std::io::Read;
2 changes: 1 addition & 1 deletion lofty/tests/tags/conversions.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Tests for special case conversions

use lofty::TextEncoding;
use lofty::id3::v2::{CommentFrame, Frame, FrameId, Id3v2Tag, UnsynchronizedTextFrame};
use lofty::tag::{ItemKey, Tag, TagType};
use lofty::TextEncoding;

use std::borrow::Cow;

2 changes: 1 addition & 1 deletion lofty_attr/src/attribute.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use syn::parse::Parse;
use syn::punctuated::Punctuated;
use syn::{token, Attribute, Expr, Ident, LitStr, Token};
use syn::{Attribute, Expr, Ident, LitStr, Token, token};

pub(crate) enum AttributeValue {
/// `#[lofty(attribute_name)]`
2 changes: 1 addition & 1 deletion lofty_attr/src/lib.rs
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ use crate::lofty_file::LoftyFile;
use crate::lofty_tag::{LoftyTag, LoftyTagAttribute};

use proc_macro::TokenStream;
use syn::{parse_macro_input, ItemStruct};
use syn::{ItemStruct, parse_macro_input};

/// Creates a file usable by Lofty
///
4 changes: 2 additions & 2 deletions lofty_attr/src/lofty_file.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use crate::{internal, util};

use proc_macro::TokenStream;
use proc_macro2::{Ident, Span};
use quote::{format_ident, quote, quote_spanned, ToTokens};
use quote::{ToTokens, format_ident, quote, quote_spanned};
use syn::parse::Parse;
use syn::spanned::Spanned;
use syn::{Attribute, Data, DataStruct, DeriveInput, Field, Fields, Type};
@@ -66,7 +66,7 @@ impl Parse for LoftyFile {
return Err(util::err(
input.ident.span(),
"This macro can only be used on structs with named fields",
))
));
},
};

2 changes: 1 addition & 1 deletion lofty_attr/src/lofty_tag.rs
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ impl Parse for LoftyTagAttribute {
return Err(Error::new(
nested_meta.span(),
"Unexpected input, check the format of the arguments",
))
));
},
}
}
4 changes: 2 additions & 2 deletions ogg_pager/src/lib.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ use std::io::{Read, Seek};

pub use crc::crc32;
pub use error::{PageError, Result};
pub use header::{PageHeader, PAGE_HEADER_SIZE};
pub use header::{PAGE_HEADER_SIZE, PageHeader};
pub use packets::{Packets, PacketsIter};
pub use paginate::paginate;

@@ -118,7 +118,7 @@ impl Page {

#[cfg(test)]
mod tests {
use crate::{paginate, Page, PageHeader};
use crate::{Page, PageHeader, paginate};
use std::io::Cursor;

pub fn segment_table(length: usize) -> Vec<u8> {
6 changes: 3 additions & 3 deletions ogg_pager/src/packets.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::Page;
use crate::error::{PageError, Result};
use crate::header::PageHeader;
use crate::paginate::paginate;
use crate::Page;

use std::fmt::{Debug, Formatter};
use std::io::{Read, Seek, Write};
@@ -332,7 +332,7 @@ impl Packets {
/// # Examples
///
/// ```rust
/// use ogg_pager::{Packets, CONTAINS_FIRST_PAGE_OF_BITSTREAM, CONTAINS_LAST_PAGE_OF_BITSTREAM};
/// use ogg_pager::{CONTAINS_FIRST_PAGE_OF_BITSTREAM, CONTAINS_LAST_PAGE_OF_BITSTREAM, Packets};
///
/// # fn main() -> Result<(), ogg_pager::PageError> {
/// # let path = "../lofty/tests/files/assets/minimal/full_test.ogg";
@@ -372,7 +372,7 @@ impl Packets {
/// # Examples
///
/// ```rust,no_run
/// use ogg_pager::{Packets, CONTAINS_FIRST_PAGE_OF_BITSTREAM, CONTAINS_LAST_PAGE_OF_BITSTREAM};
/// use ogg_pager::{CONTAINS_FIRST_PAGE_OF_BITSTREAM, CONTAINS_LAST_PAGE_OF_BITSTREAM, Packets};
/// use std::fs::OpenOptions;
///
/// # fn main() -> Result<(), ogg_pager::PageError> {
4 changes: 2 additions & 2 deletions ogg_pager/src/paginate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::error::Result;
use crate::{
Page, PageHeader, CONTAINS_FIRST_PAGE_OF_BITSTREAM, CONTAINS_LAST_PAGE_OF_BITSTREAM,
CONTINUED_PACKET, MAX_WRITTEN_CONTENT_SIZE, MAX_WRITTEN_SEGMENT_COUNT,
CONTAINS_FIRST_PAGE_OF_BITSTREAM, CONTAINS_LAST_PAGE_OF_BITSTREAM, CONTINUED_PACKET,
MAX_WRITTEN_CONTENT_SIZE, MAX_WRITTEN_SEGMENT_COUNT, Page, PageHeader,
};

use std::io::Read;
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
edition = "2021"
edition = "2024"
unstable_features = true
condense_wildcard_suffixes = true
format_code_in_doc_comments = true