From fdd6d131468eaa485c613b59cf0d2862e064d72f Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Sat, 18 Jan 2025 10:14:18 +0100 Subject: [PATCH] Correct album id-info split --- src/core/collection/album.rs | 82 +++++++++++------- src/core/musichoard/database.rs | 7 +- src/core/testmod.rs | 4 +- src/external/database/serde/deserialize.rs | 4 +- src/external/database/serde/serialize.rs | 4 +- src/testmod/full.rs | 96 ++++++++------------- src/testmod/library.rs | 40 +++------ src/tui/app/machine/match_state.rs | 12 ++- src/tui/lib/external/musicbrainz/api/mod.rs | 6 +- src/tui/testmod.rs | 4 +- src/tui/ui/browse_state.rs | 2 +- src/tui/ui/display.rs | 2 +- src/tui/ui/mod.rs | 12 ++- tests/testlib.rs | 70 ++++++--------- 14 files changed, 152 insertions(+), 193 deletions(-) diff --git a/src/core/collection/album.rs b/src/core/collection/album.rs index 9e5c7e4..7945187 100644 --- a/src/core/collection/album.rs +++ b/src/core/collection/album.rs @@ -19,14 +19,14 @@ pub struct Album { #[derive(Clone, Debug, PartialEq, Eq)] pub struct AlbumMeta { pub id: AlbumId, - pub date: AlbumDate, - pub seq: AlbumSeq, pub info: AlbumInfo, } /// Album non-identifier metadata. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct AlbumInfo { + pub date: AlbumDate, + pub seq: AlbumSeq, pub primary_type: Option, pub secondary_types: Vec, } @@ -93,6 +93,12 @@ impl From<(u32, u8, u8)> for AlbumDate { #[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash)] pub struct AlbumSeq(pub u8); +impl From for AlbumSeq { + fn from(value: u8) -> Self { + AlbumSeq(value) + } +} + /// Based on [MusicBrainz types](https://musicbrainz.org/doc/Release_Group/Type). #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum AlbumPrimaryType { @@ -181,7 +187,7 @@ impl Album { } pub fn with_date>(mut self, date: Date) -> Self { - self.meta.date = date.into(); + self.meta.info.date = date.into(); self } @@ -214,14 +220,12 @@ impl AlbumMeta { pub fn new>(id: Id) -> Self { AlbumMeta { id: id.into(), - date: AlbumDate::default(), - seq: AlbumSeq::default(), info: AlbumInfo::default(), } } pub fn with_date>(mut self, date: Date) -> Self { - self.date = date.into(); + self.info.date = date.into(); self } @@ -232,8 +236,8 @@ impl AlbumMeta { pub fn get_sort_key(&self) -> (&AlbumDate, &AlbumSeq, &str, &Option) { ( - &self.date, - &self.seq, + &self.info.date, + &self.info.seq, &self.id.title, &self.info.primary_type, ) @@ -247,6 +251,36 @@ impl AlbumMeta { self.id.clear_mb_ref(); } + pub fn set_seq(&mut self, seq: AlbumSeq) { + self.info.set_seq(seq); + } + + pub fn clear_seq(&mut self) { + self.info.clear_seq(); + } +} + +impl AlbumInfo { + pub fn with_date>(mut self, date: Date) -> Self { + self.date = date.into(); + self + } + + pub fn with_seq>(mut self, seq: Seq) -> Self { + self.seq = seq.into(); + self + } + + pub fn with_primary_type(mut self, primary_type: AlbumPrimaryType) -> Self { + self.primary_type = Some(primary_type); + self + } + + pub fn with_secondary_types(mut self, secondary_types: Vec) -> Self { + self.secondary_types = secondary_types; + self + } + pub fn set_seq(&mut self, seq: AlbumSeq) { self.seq = seq; } @@ -256,18 +290,6 @@ impl AlbumMeta { } } -impl AlbumInfo { - pub fn new( - primary_type: Option, - secondary_types: Vec, - ) -> Self { - AlbumInfo { - primary_type, - secondary_types, - } - } -} - impl PartialOrd for AlbumMeta { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) @@ -284,16 +306,16 @@ impl Merge for AlbumMeta { fn merge_in_place(&mut self, other: Self) { assert!(self.id.compatible(&other.id)); self.id.mb_ref = self.id.mb_ref.take().or(other.id.mb_ref); - if self.date.year.is_none() && other.date.year.is_some() { - self.date = other.date; - } - self.seq = std::cmp::max(self.seq, other.seq); self.info.merge_in_place(other.info); } } impl Merge for AlbumInfo { fn merge_in_place(&mut self, other: Self) { + if self.date.year.is_none() && other.date.year.is_some() { + self.date = other.date; + } + self.seq = std::cmp::max(self.seq, other.seq); self.primary_type = self.primary_type.take().or(other.primary_type); if self.secondary_types.is_empty() { self.secondary_types = other.secondary_types; @@ -385,21 +407,21 @@ mod tests { fn set_clear_seq() { let mut album = Album::new("An album"); - assert_eq!(album.meta.seq, AlbumSeq(0)); + assert_eq!(album.meta.info.seq, AlbumSeq(0)); // Setting a seq on an album. album.meta.set_seq(AlbumSeq(6)); - assert_eq!(album.meta.seq, AlbumSeq(6)); + assert_eq!(album.meta.info.seq, AlbumSeq(6)); album.meta.set_seq(AlbumSeq(6)); - assert_eq!(album.meta.seq, AlbumSeq(6)); + assert_eq!(album.meta.info.seq, AlbumSeq(6)); album.meta.set_seq(AlbumSeq(8)); - assert_eq!(album.meta.seq, AlbumSeq(8)); + assert_eq!(album.meta.info.seq, AlbumSeq(8)); // Clearing seq. album.meta.clear_seq(); - assert_eq!(album.meta.seq, AlbumSeq(0)); + assert_eq!(album.meta.info.seq, AlbumSeq(0)); } #[test] @@ -439,7 +461,7 @@ mod tests { #[test] fn merge_album_dates() { - let meta = AlbumMeta::new(AlbumId::new("An album")); + let meta = AlbumInfo::default(); // No merge if years are different. let left = meta.clone().with_date((2000, 1, 6)); diff --git a/src/core/musichoard/database.rs b/src/core/musichoard/database.rs index d73b817..3928724 100644 --- a/src/core/musichoard/database.rs +++ b/src/core/musichoard/database.rs @@ -554,10 +554,9 @@ mod tests { assert_eq!(meta.info.primary_type, None); assert_eq!(meta.info.secondary_types, Vec::new()); - let info = AlbumInfo::new( - Some(AlbumPrimaryType::Album), - vec![AlbumSecondaryType::Live], - ); + let info = AlbumInfo::default() + .with_primary_type(AlbumPrimaryType::Album) + .with_secondary_types(vec![AlbumSecondaryType::Live]); // Seting info on an album not belonging to the artist is an error. assert!(music_hoard diff --git a/src/core/testmod.rs b/src/core/testmod.rs index a812f67..0605975 100644 --- a/src/core/testmod.rs +++ b/src/core/testmod.rs @@ -2,9 +2,7 @@ use once_cell::sync::Lazy; use std::collections::HashMap; use crate::core::collection::{ - album::{ - Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq, - }, + album::{Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType}, artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta}, musicbrainz::{MbAlbumRef, MbArtistRef}, track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality}, diff --git a/src/external/database/serde/deserialize.rs b/src/external/database/serde/deserialize.rs index 5d5a302..81a1872 100644 --- a/src/external/database/serde/deserialize.rs +++ b/src/external/database/serde/deserialize.rs @@ -141,9 +141,9 @@ impl From for Album { lib_id: album.lib_id.into(), mb_ref: album.mb_ref.into(), }, - date: album.date.into(), - seq: AlbumSeq(album.seq), info: AlbumInfo { + date: album.date.into(), + seq: AlbumSeq(album.seq), primary_type: album.primary_type.map(Into::into), secondary_types: album.secondary_types.into_iter().map(Into::into).collect(), }, diff --git a/src/external/database/serde/serialize.rs b/src/external/database/serde/serialize.rs index 8f99b4b..3213c25 100644 --- a/src/external/database/serde/serialize.rs +++ b/src/external/database/serde/serialize.rs @@ -89,8 +89,8 @@ impl<'a> From<&'a Album> for SerializeAlbum<'a> { title: &album.meta.id.title, lib_id: album.meta.id.lib_id.into(), mb_ref: (&album.meta.id.mb_ref).into(), - date: album.meta.date.into(), - seq: album.meta.seq.0, + date: album.meta.info.date.into(), + seq: album.meta.info.seq.0, primary_type: album.meta.info.primary_type.map(Into::into), secondary_types: album .meta diff --git a/src/testmod/full.rs b/src/testmod/full.rs index d16c111..bc5f79b 100644 --- a/src/testmod/full.rs +++ b/src/testmod/full.rs @@ -33,12 +33,10 @@ macro_rules! full_collection { "https://musicbrainz.org/release-group/00000000-0000-0000-0000-000000000000" ).unwrap()), }, - date: 1998.into(), - seq: AlbumSeq(1), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(1998) + .with_seq(1) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -97,12 +95,10 @@ macro_rules! full_collection { lib_id: AlbumLibId::Value(2), mb_ref: AlbumMbRef::None, }, - date: (2015, 4).into(), - seq: AlbumSeq(1), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date((2015, 4)) + .with_seq(1) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -165,12 +161,10 @@ macro_rules! full_collection { lib_id: AlbumLibId::Value(3), mb_ref: AlbumMbRef::None, }, - date: (2003, 6, 6).into(), - seq: AlbumSeq(1), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date((2003, 6, 6)) + .with_seq(1) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -209,12 +203,10 @@ macro_rules! full_collection { "https://musicbrainz.org/release-group/11111111-1111-1111-1111-111111111111" ).unwrap()), }, - date: 2008.into(), - seq: AlbumSeq(3), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(2008) + .with_seq(3) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -253,12 +245,10 @@ macro_rules! full_collection { "https://musicbrainz.org/release-group/11111111-1111-1111-1111-111111111112" ).unwrap()), }, - date: 2009.into(), - seq: AlbumSeq(2), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(2009) + .with_seq(2) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -295,12 +285,10 @@ macro_rules! full_collection { lib_id: AlbumLibId::Value(6), mb_ref: AlbumMbRef::None, }, - date: 2015.into(), - seq: AlbumSeq(4), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(2015) + .with_seq(4) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -351,12 +339,9 @@ macro_rules! full_collection { lib_id: AlbumLibId::Value(7), mb_ref: AlbumMbRef::None, }, - date: 1985.into(), - seq: AlbumSeq(0), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(1985) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -393,12 +378,9 @@ macro_rules! full_collection { lib_id: AlbumLibId::Value(8), mb_ref: AlbumMbRef::None, }, - date: 2018.into(), - seq: AlbumSeq(0), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(2018) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -449,12 +431,9 @@ macro_rules! full_collection { lib_id: AlbumLibId::Value(9), mb_ref: AlbumMbRef::None, }, - date: 1995.into(), - seq: AlbumSeq(0), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(1995) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -491,12 +470,9 @@ macro_rules! full_collection { lib_id: AlbumLibId::Value(10), mb_ref: AlbumMbRef::None, }, - date: 2028.into(), - seq: AlbumSeq(0), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(2028) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { diff --git a/src/testmod/library.rs b/src/testmod/library.rs index f8cc7db..c5d0cfb 100644 --- a/src/testmod/library.rs +++ b/src/testmod/library.rs @@ -21,9 +21,7 @@ macro_rules! library_collection { lib_id: AlbumLibId::Value(1), mb_ref: AlbumMbRef::None, }, - date: 1998.into(), - seq: AlbumSeq(0), - info: AlbumInfo::default(), + info: AlbumInfo::default().with_date(1998), }, tracks: vec![ Track { @@ -82,9 +80,7 @@ macro_rules! library_collection { lib_id: AlbumLibId::Value(2), mb_ref: AlbumMbRef::None, }, - date: (2015, 4).into(), - seq: AlbumSeq(0), - info: AlbumInfo::default(), + info: AlbumInfo::default().with_date((2015, 4)), }, tracks: vec![ Track { @@ -132,9 +128,7 @@ macro_rules! library_collection { lib_id: AlbumLibId::Value(3), mb_ref: AlbumMbRef::None, }, - date: (2003, 6, 6).into(), - seq: AlbumSeq(0), - info: AlbumInfo::default(), + info: AlbumInfo::default().with_date((2003, 6, 6)), }, tracks: vec![ Track { @@ -171,9 +165,7 @@ macro_rules! library_collection { lib_id: AlbumLibId::Value(4), mb_ref: AlbumMbRef::None, }, - date: 2008.into(), - seq: AlbumSeq(0), - info: AlbumInfo::default(), + info: AlbumInfo::default().with_date(2008), }, tracks: vec![ Track { @@ -210,9 +202,7 @@ macro_rules! library_collection { lib_id: AlbumLibId::Value(5), mb_ref: AlbumMbRef::None, }, - date: 2009.into(), - seq: AlbumSeq(0), - info: AlbumInfo::default(), + info: AlbumInfo::default().with_date(2009), }, tracks: vec![ Track { @@ -249,9 +239,7 @@ macro_rules! library_collection { lib_id: AlbumLibId::Value(6), mb_ref: AlbumMbRef::None, }, - date: 2015.into(), - seq: AlbumSeq(0), - info: AlbumInfo::default(), + info: AlbumInfo::default().with_date(2015), }, tracks: vec![ Track { @@ -302,9 +290,7 @@ macro_rules! library_collection { lib_id: AlbumLibId::Value(7), mb_ref: AlbumMbRef::None, }, - date: 1985.into(), - seq: AlbumSeq(0), - info: AlbumInfo::default(), + info: AlbumInfo::default().with_date(1985), }, tracks: vec![ Track { @@ -341,9 +327,7 @@ macro_rules! library_collection { lib_id: AlbumLibId::Value(8), mb_ref: AlbumMbRef::None, }, - date: 2018.into(), - seq: AlbumSeq(0), - info: AlbumInfo::default(), + info: AlbumInfo::default().with_date(2018), }, tracks: vec![ Track { @@ -394,9 +378,7 @@ macro_rules! library_collection { lib_id: AlbumLibId::Value(9), mb_ref: AlbumMbRef::None, }, - date: 1995.into(), - seq: AlbumSeq(0), - info: AlbumInfo::default(), + info: AlbumInfo::default().with_date(1995), }, tracks: vec![ Track { @@ -433,9 +415,7 @@ macro_rules! library_collection { lib_id: AlbumLibId::Value(10), mb_ref: AlbumMbRef::None, }, - date: 2028.into(), - seq: AlbumSeq(0), - info: AlbumInfo::default(), + info: AlbumInfo::default().with_date(2028), }, tracks: vec![ Track { diff --git a/src/tui/app/machine/match_state.rs b/src/tui/app/machine/match_state.rs index 7abbef1..b6f4f2d 100644 --- a/src/tui/app/machine/match_state.rs +++ b/src/tui/app/machine/match_state.rs @@ -393,10 +393,14 @@ mod tests { fn album_meta(id: AlbumId) -> AlbumMeta { AlbumMeta::new(id) .with_date(AlbumDate::new(Some(1990), Some(5), None)) - .with_info(AlbumInfo::new( - Some(AlbumPrimaryType::Album), - vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation], - )) + .with_info( + AlbumInfo::default() + .with_primary_type(AlbumPrimaryType::Album) + .with_secondary_types(vec![ + AlbumSecondaryType::Live, + AlbumSecondaryType::Compilation, + ]), + ) } fn album_match() -> EntityMatches { diff --git a/src/tui/lib/external/musicbrainz/api/mod.rs b/src/tui/lib/external/musicbrainz/api/mod.rs index 1ec116d..49d5c69 100644 --- a/src/tui/lib/external/musicbrainz/api/mod.rs +++ b/src/tui/lib/external/musicbrainz/api/mod.rs @@ -75,7 +75,7 @@ impl IMusicBrainz for MusicBrainz { ) -> Result>, Error> { // Some release groups may have a promotional early release messing up the search. Searching // with just the year should be enough anyway. - let date = AlbumDate::new(album.date.year, None, None); + let date = AlbumDate::new(album.info.date.year, None, None); let query = SearchReleaseGroupRequest::new() .arid(arid) @@ -135,9 +135,9 @@ fn from_mb_release_group_meta(meta: MbReleaseGroupMeta) -> AlbumMeta { lib_id: AlbumLibId::None, mb_ref: AlbumMbRef::Some(meta.id.into()), }, - date: meta.first_release_date, - seq: AlbumSeq::default(), info: AlbumInfo { + date: meta.first_release_date, + seq: AlbumSeq::default(), primary_type: meta.primary_type, secondary_types: meta.secondary_types.unwrap_or_default(), }, diff --git a/src/tui/testmod.rs b/src/tui/testmod.rs index 6346109..6c71186 100644 --- a/src/tui/testmod.rs +++ b/src/tui/testmod.rs @@ -1,9 +1,7 @@ use std::collections::HashMap; use musichoard::collection::{ - album::{ - Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq, - }, + album::{Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType}, artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta}, musicbrainz::{MbAlbumRef, MbArtistRef}, track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality}, diff --git a/src/tui/ui/browse_state.rs b/src/tui/ui/browse_state.rs index a99e195..b53e5b1 100644 --- a/src/tui/ui/browse_state.rs +++ b/src/tui/ui/browse_state.rs @@ -166,7 +166,7 @@ impl<'a, 'b> AlbumState<'a, 'b> { Ownership: {}", album.map(|a| a.meta.id.title.as_str()).unwrap_or(""), album - .map(|a| UiDisplay::display_date(&a.meta.date, &a.meta.seq)) + .map(|a| UiDisplay::display_date(&a.meta.info.date, &a.meta.info.seq)) .unwrap_or_default(), album .map(|a| UiDisplay::display_album_type( diff --git a/src/tui/ui/display.rs b/src/tui/ui/display.rs index 1c91792..efdb03d 100644 --- a/src/tui/ui/display.rs +++ b/src/tui/ui/display.rs @@ -171,7 +171,7 @@ impl UiDisplay { fn display_option_album(album: &AlbumMeta, _disambiguation: &Option) -> String { format!( "{:010} | {} [{}]", - UiDisplay::display_album_date(&album.date), + UiDisplay::display_album_date(&album.info.date), album.id.title, UiDisplay::display_album_type(&album.info.primary_type, &album.info.secondary_types), ) diff --git a/src/tui/ui/mod.rs b/src/tui/ui/mod.rs index c3e3ee3..b281816 100644 --- a/src/tui/ui/mod.rs +++ b/src/tui/ui/mod.rs @@ -360,10 +360,14 @@ mod tests { fn album_meta(id: AlbumId) -> AlbumMeta { AlbumMeta::new(id) .with_date(AlbumDate::new(Some(1990), Some(5), None)) - .with_info(AlbumInfo::new( - Some(AlbumPrimaryType::Album), - vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation], - )) + .with_info( + AlbumInfo::default() + .with_primary_type(AlbumPrimaryType::Album) + .with_secondary_types(vec![ + AlbumSecondaryType::Live, + AlbumSecondaryType::Compilation, + ]), + ) } fn album_matches() -> EntityMatches { diff --git a/tests/testlib.rs b/tests/testlib.rs index 36a0035..a244c31 100644 --- a/tests/testlib.rs +++ b/tests/testlib.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use musichoard::collection::{ album::{ Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, - AlbumSecondaryType, AlbumSeq, + AlbumSecondaryType, }, artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta}, musicbrainz::MbArtistRef, @@ -44,12 +44,9 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { lib_id: AlbumLibId::Value(7), mb_ref: AlbumMbRef::None, }, - date: 2011.into(), - seq: AlbumSeq(0), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(2011) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -237,12 +234,9 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { lib_id: AlbumLibId::Value(1), mb_ref: AlbumMbRef::None, }, - date: 2004.into(), - seq: AlbumSeq(0), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Ep), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(2004) + .with_primary_type(AlbumPrimaryType::Ep), }, tracks: vec![ Track { @@ -320,12 +314,9 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { lib_id: AlbumLibId::Value(2), mb_ref: AlbumMbRef::None, }, - date: 2008.into(), - seq: AlbumSeq(0), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(2008) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -491,12 +482,9 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { lib_id: AlbumLibId::Value(3), mb_ref: AlbumMbRef::None, }, - date: 2001.into(), - seq: AlbumSeq(0), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(2001) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -650,9 +638,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { lib_id: AlbumLibId::Singleton, mb_ref: AlbumMbRef::None, }, - date: 2011.into(), - seq: AlbumSeq(0), - info: AlbumInfo::default(), + info: AlbumInfo::default().with_date(2011), }, tracks: vec![ Track { @@ -674,12 +660,9 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { lib_id: AlbumLibId::Value(4), mb_ref: AlbumMbRef::None, }, - date: 2011.into(), - seq: AlbumSeq(0), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(2011) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -790,12 +773,9 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { lib_id: AlbumLibId::Value(5), mb_ref: AlbumMbRef::None, }, - date: 1984.into(), - seq: AlbumSeq(0), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![], - }, + info: AlbumInfo::default() + .with_date(1984) + .with_primary_type(AlbumPrimaryType::Album), }, tracks: vec![ Track { @@ -895,12 +875,10 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { lib_id: AlbumLibId::Value(6), mb_ref: AlbumMbRef::None, }, - date: 1999.into(), - seq: AlbumSeq(0), - info: AlbumInfo { - primary_type: Some(AlbumPrimaryType::Album), - secondary_types: vec![AlbumSecondaryType::Live], - }, + info: AlbumInfo::default() + .with_date(1999) + .with_primary_type(AlbumPrimaryType::Album) + .with_secondary_types(vec![AlbumSecondaryType::Live]), }, tracks: vec![ Track {