common/types: implement serialization helpers for Tag

This commit is contained in:
2025-11-21 18:36:18 +09:00
parent f07f90aee5
commit e4ece7d6b2

View File

@@ -118,4 +118,86 @@ impl Tag {
other => Self::Other(other.to_string(), value),
}
}
pub fn key(&self) -> &str {
match self {
Tag::Artist(_) => "Artist",
Tag::ArtistSort(_) => "ArtistSort",
Tag::Album(_) => "Album",
Tag::AlbumSort(_) => "AlbumSort",
Tag::AlbumArtist(_) => "AlbumArtist",
Tag::AlbumArtistSort(_) => "AlbumArtistSort",
Tag::Title(_) => "Title",
Tag::TitleSort(_) => "TitleSort",
Tag::Track(_) => "Track",
Tag::Name(_) => "Name",
Tag::Genre(_) => "Genre",
Tag::Mood(_) => "Mood",
Tag::Date(_) => "Date",
Tag::OriginalDate(_) => "OriginalDate",
Tag::Composer(_) => "Composer",
Tag::ComposerSort(_) => "ComposerSort",
Tag::Performer(_) => "Performer",
Tag::Conductor(_) => "Conductor",
Tag::Work(_) => "Work",
Tag::Ensemble(_) => "Ensemble",
Tag::Movement(_) => "Movement",
Tag::MovementNumber(_) => "MovementNumber",
Tag::ShowMovement(_) => "ShowMovement",
Tag::Location(_) => "Location",
Tag::Grouping(_) => "Grouping",
Tag::Comment(_) => "Comment",
Tag::Disc(_) => "Disc",
Tag::Label(_) => "Label",
Tag::MusicBrainzArtistId(_) => "MusicBrainzArtistId",
Tag::MusicBrainzAlbumId(_) => "MusicBrainzAlbumId",
Tag::MusicBrainzAlbumArtistId(_) => "MusicBrainzAlbumArtistId",
Tag::MusicBrainzTrackId(_) => "MusicBrainzTrackId",
Tag::MusicBrainzReleaseGroupId(_) => "MusicBrainzReleaseGroupId",
Tag::MusicBrainzReleaseTrackId(_) => "MusicBrainzReleaseTrackId",
Tag::MusicBrainzWorkId(_) => "MusicBrainzWorkId",
Tag::Other(key, _) => key,
}
}
pub fn value(&self) -> &str {
match self {
Tag::Artist(v)
| Tag::ArtistSort(v)
| Tag::Album(v)
| Tag::AlbumSort(v)
| Tag::AlbumArtist(v)
| Tag::AlbumArtistSort(v)
| Tag::Title(v)
| Tag::TitleSort(v)
| Tag::Track(v)
| Tag::Name(v)
| Tag::Genre(v)
| Tag::Mood(v)
| Tag::Date(v)
| Tag::OriginalDate(v)
| Tag::Composer(v)
| Tag::ComposerSort(v)
| Tag::Performer(v)
| Tag::Conductor(v)
| Tag::Work(v)
| Tag::Ensemble(v)
| Tag::Movement(v)
| Tag::MovementNumber(v)
| Tag::ShowMovement(v)
| Tag::Location(v)
| Tag::Grouping(v)
| Tag::Comment(v)
| Tag::Disc(v)
| Tag::Label(v)
| Tag::MusicBrainzArtistId(v)
| Tag::MusicBrainzAlbumId(v)
| Tag::MusicBrainzAlbumArtistId(v)
| Tag::MusicBrainzTrackId(v)
| Tag::MusicBrainzReleaseGroupId(v)
| Tag::MusicBrainzReleaseTrackId(v)
| Tag::MusicBrainzWorkId(v)
| Tag::Other(_, v) => v,
}
}
}