diff --git a/CHANGELOG.md b/CHANGELOG.md index 7175880d1..0a4307232 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **ItemKey**: `ItemKey::AlbumArtists`, available for ID3v2, Vorbis Comments, APE, and MP4 Ilst ([PR](https://github.com/Serial-ATA/lofty-rs/pull/523)) - This is a multi-value item that stores each artist for a track. It should be retrieved with `Tag::get_strings` or `Tag::take_strings`. - For example, a track has `ItemKey::TrackArtist` = "Foo & Bar", then `ItemKey::AlbumArtists` = ["Foo", "Bar"]. +- **Serde**: [Serde] support for `*Type` enums (`FileType`, `TagType`, `PictureType`) + - Support can be enabled with the new `serde` feature (not enabled by default) ### Changed - **ID3v2**: Check `TXXX:ALBUMARTIST` and `TXXX:ALBUM ARTIST` for `ItemKey::AlbumArtist` conversions @@ -1012,5 +1014,6 @@ See [ogg_pager's changelog](ogg_pager/CHANGELOG.md). [0.5.1]: https://github.com/Serial-ATA/lofty-rs/compare/0.5.0...0.5.1 [0.5.0]: https://github.com/Serial-ATA/lofty-rs/compare/64f0eff...0.5.0 +[serde]: https://docs.rs/serde [TagLib]: https://github.com/taglib/taglib [ogg_pager's changelog]: ogg_pager/CHANGELOG.md diff --git a/lofty/Cargo.toml b/lofty/Cargo.toml index 210748e98..2552234d2 100644 --- a/lofty/Cargo.toml +++ b/lofty/Cargo.toml @@ -30,6 +30,12 @@ paste = "1.0.15" [features] default = ["id3v2_compression_support"] id3v2_compression_support = ["dep:flate2"] +serde = ["dep:serde"] + +[dependencies.serde] +version = "1.0" +features = ["derive"] +optional = true [dev-dependencies] # WAV properties validity tests diff --git a/lofty/src/file/file_type.rs b/lofty/src/file/file_type.rs index 30f7a13e8..d401a7adc 100644 --- a/lofty/src/file/file_type.rs +++ b/lofty/src/file/file_type.rs @@ -6,7 +6,9 @@ use std::ffi::OsStr; use std::path::Path; /// The type of file read +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(PartialEq, Eq, Copy, Clone, Debug)] +#[allow(clippy::unsafe_derive_deserialize)] #[allow(missing_docs)] #[non_exhaustive] pub enum FileType { diff --git a/lofty/src/picture.rs b/lofty/src/picture.rs index faf1c7ba4..a813be783 100644 --- a/lofty/src/picture.rs +++ b/lofty/src/picture.rs @@ -130,6 +130,8 @@ impl Display for MimeType { /// The picture type, according to ID3v2 APIC #[allow(missing_docs)] +#[allow(clippy::unsafe_derive_deserialize)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] #[non_exhaustive] pub enum PictureType { diff --git a/lofty/src/tag/tag_type.rs b/lofty/src/tag/tag_type.rs index b3b2103a7..cee014326 100644 --- a/lofty/src/tag/tag_type.rs +++ b/lofty/src/tag/tag_type.rs @@ -10,7 +10,9 @@ use std::fs::OpenOptions; use std::path::Path; /// The tag's format +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[allow(clippy::unsafe_derive_deserialize)] #[non_exhaustive] pub enum TagType { /// This covers both APEv1 and APEv2 as it doesn't matter much