Skip to content

Commit 4a2bcb4

Browse files
docs: fixes, comments, and examples
Co-authored-by: Serial <69764315+serial-ata@users.noreply.github.com>
1 parent 2497325 commit 4a2bcb4

23 files changed

Lines changed: 389 additions & 89 deletions

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
- **APE**: The `Tag` -> `ApeTag` conversion will now preserve multi-value items ([issue](https://github.com/Serial-ATA/lofty-rs/issues/631)) ([PR](https://github.com/Serial-ATA/lofty-rs/pull/633))
1818

19+
### Removed
20+
21+
- **ItemKey**: `ItemKey::FileType` and `ItemKey::MusicianCredits` ([PR](https://github.com/Serial-ATA/lofty-rs/pull/636))
22+
- These are ID3v2-specific fields with special formats.
23+
1924
## [0.23.3] - 2026-03-14
2025

2126
### Added

doc/ISSUES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ The "[MISC] Feature Request" issue template is for feature requests that either:
9797

9898
The "[API] Feature Request" issue template is for feature requests that have a specific design.
9999

100-
If you have an feature with an exact idea of how it should be used, be sure to use this template.
100+
If you have a feature with an exact idea of how it should be used, be sure to use this template.
101101

102102
The "API design" form should only serve as a design, not an implementation.
103103

doc/NEW_FILE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Now that the directories are created, we can start working on defining our file.
5757

5858
Before we can define the file struct, we need to add a variant to `FileType`.
5959

60-
Go to [src/file.rs](../src/file.rs) and edit the `FileType` enum to add your new variant.
60+
Go to [src/file/file_type.rs](../lofty/src/file/file_type.rs) and edit the `FileType` enum to add your new variant.
6161

6262
```rust
6363
pub enum FileType {
@@ -216,7 +216,8 @@ They can be easily defined in a few lines:
216216
use std::io::Cursor;
217217

218218
use libfuzzer_sys::fuzz_target;
219-
use lofty::{AudioFile, ParseOptions};
219+
use lofty::config::ParseOptions;
220+
use lofty::file::AudioFile;
220221

221222
fuzz_target!(|data: Vec<u8>| {
222223
let _ = lofty::foo::FooFile::read_from(

doc/NEW_TAG.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ This document will cover the implementation of a tag file format named "Foo".
3535
To define a new tag format, first determine if it is supported by a single format. In this example it is,
3636
so we would place its definition in a subdirectory of the `foo` directory, where we defined the Foo audio format.
3737
If this was a generic tag format supported by multiple audio formats, like ID3, you'd simply define it in its own
38-
folder inside [src/](../src).
38+
folder inside [src/](../lofty/src).
3939

4040
There are some files that every tag needs:
4141

@@ -62,7 +62,7 @@ Now that the directories are created, we can start working on defining our file.
6262

6363
Before we can define the tag struct, we need to add a variant to `TagType`.
6464

65-
Go to [src/tag/mod.rs](../src/tag/mod.rs) and edit the `TagType` enum to add your new variant.
65+
Go to [src/tag/mod.rs](../lofty/src/tag/mod.rs) and edit the `TagType` enum to add your new variant.
6666

6767
```rust
6868
pub enum TagType {
@@ -149,7 +149,7 @@ impl Accessor for FooTag {
149149

150150
fn artist(&self) -> Option<Cow<'_, str>> { /**/ }
151151
fn set_artist(&mut self, value: String) { /**/ }
152-
fn remove_artist() { /**/ }
152+
fn remove_artist(&mut self) { /**/ }
153153

154154
fn album(&self) -> Option<Cow<'_, str>> { /**/ }
155155
fn set_album(&mut self, value: String) { /**/ }
@@ -187,8 +187,8 @@ impl FooTag {
187187
self.items.push((key, value))
188188
}
189189

190-
pub fn remove<'a>(&'a mut self, key: &str) -> impl Iterator<Item=String> + use<'a> {
191-
self.items.retain(|(k, _)| !k.eq_ignore_ascii_case(&key));
190+
pub fn remove(&mut self, key: &str) {
191+
self.items.retain(|(k, _)| !k.eq_ignore_ascii_case(key));
192192
}
193193
}
194194
```
@@ -240,7 +240,7 @@ Converting your concrete tag type into the generic `Tag` involves the following:
240240

241241
##### Defining Generic Mappings
242242

243-
The `ItemKey` mappings are defined in [src/tag/item.rs](../src/tag/item.rs).
243+
The `ItemKey` mappings are defined in [src/tag/item.rs](../lofty/src/tag/item.rs).
244244

245245
See the comments for the `gen_map!` macro, which explains its use in detail, and will be kept up to
246246
date with any future changes.
@@ -411,7 +411,7 @@ TODO
411411

412412
#### Assets
413413

414-
Test assets for tag formats are to be placed in [tests/tags/assets/](../tests/tags/assets).
414+
Test assets for tag formats are to be placed in [tests/tags/assets/](../lofty/tests/tags/assets).
415415

416416
There should at least be one asset, which is a binary file containing the tag below:
417417

@@ -444,12 +444,12 @@ There are at least 4 unit tests that should be created for every tag format:
444444
* Using `crate::tag::utils::test_utils::create_tag()`, verify that the converted tag is correct
445445

446446
These tests should be placed in the tag's `read` module. If there are many tests, feel free to break them out
447-
into their own module (ex. See the [ID3v2 `tests` module](../src/id3/v2/tag)).
447+
into their own module (ex. See the [ID3v2 `tests` module](../lofty/src/id3/v2/tag)).
448448

449449
For an example of these tests, see the [ApeTag tests](https://github.com/Serial-ATA/lofty-rs/blob/9c0ea926c690bc6338ba95aceccc4d93e2ee9826/src/ape/tag/mod.rs#L540-L656).
450450

451451
#### Integration Tests
452452

453453
Integration testing is not normally necessary for tag formats, as they are typically
454454
tested extensively through the module's unit tests. However, if one wants to create integration tests,
455-
they can be placed in [tests/tags/](../tests/tags).
455+
they can be placed in [tests/tags/](../lofty/tests/tags).

doc/PULL_REQUESTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
Before you create a PR, we ask that you do the following:
1515

1616
1. **If fixing a bug, make an issue first**: The issue tracker should have a searchable history of
17-
bugs reports.
17+
bug reports.
1818

1919
2. **If adding a feature, make an issue or discussion first**: Features should be discussed prior to implementation.
2020

lofty/src/file/file_type.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,33 @@ pub const EXTENSIONS: &[&str] = &[
4747
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4848
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
4949
#[allow(clippy::unsafe_derive_deserialize)]
50-
#[allow(missing_docs)]
5150
#[non_exhaustive]
5251
pub enum FileType {
52+
/// Advanced Audio Coding (AAC/ADTS)
5353
Aac,
54+
/// Audio Interchange File Format
5455
Aiff,
56+
/// Monkey's Audio
5557
Ape,
58+
/// Free Lossless Audio Codec
5659
Flac,
60+
/// MPEG-1/2 Audio (MP1, MP2, MP3)
5761
Mpeg,
62+
/// MPEG-4 Audio (M4A, M4B, etc.)
5863
Mp4,
64+
/// Musepack
5965
Mpc,
66+
/// Opus
6067
Opus,
68+
/// Ogg Vorbis
6169
Vorbis,
70+
/// Speex
6271
Speex,
72+
/// Waveform Audio
6373
Wav,
74+
/// WavPack
6475
WavPack,
76+
/// A custom file type, registered through [`register_custom_resolver`](crate::resolve::register_custom_resolver)
6577
Custom(&'static str),
6678
}
6779

lofty/src/id3/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//! ID3 specific items
22
//!
3-
//! ID3 does things differently than other tags, making working with them a little more effort than other formats.
4-
//! Check the other modules for important notes and/or warnings.
3+
//! This covers both [`v1`] (ID3v1) and [`v2`] (ID3v2) tag formats.
4+
//!
5+
//! ID3 does things differently than other tags, making them a little more cumbersome to work with.
6+
//! Check the other modules for important notes and warnings.
57
68
pub mod v1;
79
pub mod v2;

lofty/src/id3/v2/frame/header/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use std::fmt::{Display, Formatter};
1414
/// These are rarely constructed by hand. Usually they are created in the background
1515
/// when making a new [`Frame`](crate::id3::v2::Frame).
1616
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
17-
#[allow(missing_docs)]
1817
pub struct FrameHeader<'a> {
1918
pub(crate) id: FrameId<'a>,
19+
/// The frame's flags
2020
pub flags: FrameFlags,
2121
}
2222

lofty/src/id3/v2/items/event_timing_codes_frame.rs

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,54 +22,93 @@ const FRAME_ID: FrameId<'static> = FrameId::Valid(Cow::Borrowed("ETCO"));
2222
/// >>> like setting off an explosion on-stage, activating a screensaver etc.
2323
#[repr(u8)]
2424
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
25-
#[allow(missing_docs)]
2625
pub enum EventType {
26+
/// Padding (has no meaning)
2727
Padding = 0x00,
28+
/// End of initial silence
2829
EndOfInitialSilence = 0x01,
30+
/// Intro start
2931
IntroStart = 0x02,
32+
/// Main part start
3033
MainPartStart = 0x03,
34+
/// Outro start
3135
OutroStart = 0x04,
36+
/// Outro end
3237
OutroEnd = 0x05,
38+
/// Verse start
3339
VerseStart = 0x06,
40+
/// Refrain start
3441
RefrainStart = 0x07,
42+
/// Interlude start
3543
InterludeStart = 0x08,
44+
/// Theme start
3645
ThemeStart = 0x09,
46+
/// Variation start
3747
VariationStart = 0x0A,
48+
/// Key change
3849
KeyChange = 0x0B,
50+
/// Time change
3951
TimeChange = 0x0C,
52+
/// Momentary unwanted noise (Alarm, Phone, etc.)
4053
MomentaryUnwantedNoise = 0x0D,
54+
/// Sustained noise
4155
SustainedNoise = 0x0E,
56+
/// Sustained noise end
4257
SustainedNoiseEnd = 0x0F,
58+
/// Intro end
4359
IntroEnd = 0x10,
60+
/// Main part end
4461
MainPartEnd = 0x11,
62+
/// Verse end
4563
VerseEnd = 0x12,
64+
/// Refrain end
4665
RefrainEnd = 0x13,
66+
/// Theme end
4767
ThemeEnd = 0x14,
68+
/// Profanity
4869
Profanity = 0x15,
70+
/// Profanity end
4971
ProfanityEnd = 0x16,
5072

51-
// User-defined events
73+
/// Not predefined synch 0 (user event)
5274
NotPredefinedSynch0 = 0xE0,
75+
/// Not predefined synch 1 (user event)
5376
NotPredefinedSynch1 = 0xE1,
77+
/// Not predefined synch 2 (user event)
5478
NotPredefinedSynch2 = 0xE2,
79+
/// Not predefined synch 3 (user event)
5580
NotPredefinedSynch3 = 0xE3,
81+
/// Not predefined synch 4 (user event)
5682
NotPredefinedSynch4 = 0xE4,
83+
/// Not predefined synch 5 (user event)
5784
NotPredefinedSynch5 = 0xE5,
85+
/// Not predefined synch 6 (user event)
5886
NotPredefinedSynch6 = 0xE6,
87+
/// Not predefined synch 7 (user event)
5988
NotPredefinedSynch7 = 0xE7,
89+
/// Not predefined synch 8 (user event)
6090
NotPredefinedSynch8 = 0xE8,
91+
/// Not predefined synch 9 (user event)
6192
NotPredefinedSynch9 = 0xE9,
93+
/// Not predefined synch A (user event)
6294
NotPredefinedSynchA = 0xEA,
95+
/// Not predefined synch B (user event)
6396
NotPredefinedSynchB = 0xEB,
97+
/// Not predefined synch C (user event)
6498
NotPredefinedSynchC = 0xEC,
99+
/// Not predefined synch D (user event)
65100
NotPredefinedSynchD = 0xED,
101+
/// Not predefined synch E (user event)
66102
NotPredefinedSynchE = 0xEE,
103+
/// Not predefined synch F (user event)
67104
NotPredefinedSynchF = 0xEF,
68105

106+
/// Audio end (start of silence)
69107
AudioEnd = 0xFD,
108+
/// Audio file ends
70109
AudioFileEnds = 0xFE,
71110

72-
/// 0x17..=0xDF and 0xF0..=0xFC
111+
/// Reserved event type (0x17..=0xDF and 0xF0..=0xFC)
73112
Reserved,
74113
}
75114

lofty/src/id3/v2/items/relative_volume_adjustment_frame.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,24 @@ const FRAME_ID: FrameId<'static> = FrameId::Valid(Cow::Borrowed("RVA2"));
1616
/// A channel identifier used in the RVA2 frame
1717
#[repr(u8)]
1818
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
19-
#[allow(missing_docs)]
2019
pub enum ChannelType {
20+
/// Other channel type
2121
Other = 0,
22+
/// Master volume
2223
MasterVolume = 1,
24+
/// Front right
2325
FrontRight = 2,
26+
/// Front left
2427
FrontLeft = 3,
28+
/// Back right
2529
BackRight = 4,
30+
/// Back left
2631
BackLeft = 5,
32+
/// Front centre
2733
FrontCentre = 6,
34+
/// Back centre
2835
BackCentre = 7,
36+
/// Subwoofer
2937
Subwoofer = 8,
3038
}
3139

0 commit comments

Comments
 (0)