Skip to content

Commit 9e09487

Browse files
LepidopteranSerial-ATA
authored andcommitted
feat: add optional serde support for *Type enums
1 parent 9b68924 commit 9e09487

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

lofty/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ paste = "1.0.15"
3030
[features]
3131
default = ["id3v2_compression_support"]
3232
id3v2_compression_support = ["dep:flate2"]
33+
serde = ["dep:serde"]
34+
35+
[dependencies.serde]
36+
version = "1.0"
37+
features = ["derive"]
38+
optional = true
3339

3440
[dev-dependencies]
3541
# WAV properties validity tests

lofty/src/file/file_type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::ffi::OsStr;
66
use std::path::Path;
77

88
/// The type of file read
9+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
910
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
1011
#[allow(missing_docs)]
1112
#[non_exhaustive]

lofty/src/picture.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub const APE_PICTURE_TYPES: [&str; 21] = [
3838
];
3939

4040
/// MIME types for pictures.
41+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4142
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
4243
#[non_exhaustive]
4344
pub enum MimeType {
@@ -130,6 +131,7 @@ impl Display for MimeType {
130131

131132
/// The picture type, according to ID3v2 APIC
132133
#[allow(missing_docs)]
134+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
133135
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
134136
#[non_exhaustive]
135137
pub enum PictureType {
@@ -279,6 +281,7 @@ impl PictureType {
279281
///
280282
/// This information is necessary for FLAC's `METADATA_BLOCK_PICTURE`.
281283
/// See [`Picture::as_flac_bytes`] for more information.
284+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
282285
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]
283286
pub struct PictureInformation {
284287
/// The picture's width in pixels

lofty/src/tag/tag_type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::fs::OpenOptions;
1010
use std::path::Path;
1111

1212
/// The tag's format
13+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1314
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
1415
#[non_exhaustive]
1516
pub enum TagType {

0 commit comments

Comments
 (0)