diff --git a/src/database/json/mod.rs b/src/database/json/mod.rs index 38b6aec..5f1a42c 100644 --- a/src/database/json/mod.rs +++ b/src/database/json/mod.rs @@ -73,8 +73,8 @@ mod tests { let mut tracks: Vec = vec![]; for track in album.tracks.iter() { - let track_number = track.number; - let track_title = &track.title; + let track_number = track.id.number; + let track_title = &track.id.title; let mut track_artist: Vec = vec![]; for artist in track.artist.iter() { @@ -89,8 +89,7 @@ mod tests { tracks.push(format!( "{{\ - \"number\":{track_number},\ - \"title\":\"{track_title}\",\ + \"id\":{{\"number\":{track_number},\"title\":\"{track_title}\"}},\ \"artist\":[{track_artist}],\ \"quality\":{{\"format\":\"{track_format}\",\"bitrate\":{track_bitrate}}}\ }}" diff --git a/src/lib.rs b/src/lib.rs index e356f84..b3d070d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,28 +30,30 @@ pub struct Quality { pub bitrate: u32, } +/// The track identifier. +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct TrackId { + pub number: u32, + pub title: String, +} + /// A single track on an album. #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub struct Track { - pub number: u32, - pub title: String, + pub id: TrackId, pub artist: Vec, pub quality: Quality, } impl PartialOrd for Track { fn partial_cmp(&self, other: &Self) -> Option { - let id = (&self.number, &self.title); - let other_id = (&other.number, &other.title); - id.partial_cmp(&other_id) + self.id.partial_cmp(&other.id) } } impl Ord for Track { fn cmp(&self, other: &Self) -> std::cmp::Ordering { - let id = (&self.number, &self.title); - let other_id = (&other.number, &other.title); - id.cmp(&other_id) + self.id.cmp(&other.id) } } @@ -200,8 +202,10 @@ impl MusicHoard { }; let track = Track { - number: item.track_number, - title: item.track_title, + id: TrackId { + number: item.track_number, + title: item.track_title, + }, artist: item.track_artist, quality: Quality { format: item.track_format, @@ -278,8 +282,8 @@ mod tests { album_artist: artist.id.name.clone(), album_year: album.id.year, album_title: album.id.title.clone(), - track_number: track.number, - track_title: track.title.clone(), + track_number: track.id.number, + track_title: track.id.title.clone(), track_artist: track.artist.clone(), track_format: track.quality.format, track_bitrate: track.quality.bitrate, diff --git a/src/testlib.rs b/src/testlib.rs index 95703ca..819bae3 100644 --- a/src/testlib.rs +++ b/src/testlib.rs @@ -13,8 +13,10 @@ macro_rules! collection { }, tracks: vec![ Track { - number: 1, - title: "track a.a.1".to_string(), + id: TrackId{ + number: 1, + title: "track a.a.1".to_string(), + }, artist: vec!["artist a.a.1".to_string()], quality: Quality { format: Format::Flac, @@ -22,8 +24,10 @@ macro_rules! collection { }, }, Track { - number: 2, - title: "track a.a.2".to_string(), + id: TrackId{ + number: 2, + title: "track a.a.2".to_string(), + }, artist: vec![ "artist a.a.2.1".to_string(), "artist a.a.2.2".to_string(), @@ -34,8 +38,10 @@ macro_rules! collection { }, }, Track { - number: 3, - title: "track a.a.3".to_string(), + id: TrackId{ + number: 3, + title: "track a.a.3".to_string(), + }, artist: vec!["artist a.a.3".to_string()], quality: Quality { format: Format::Flac, @@ -51,8 +57,10 @@ macro_rules! collection { }, tracks: vec![ Track { - number: 1, - title: "track a.b.1".to_string(), + id: TrackId{ + number: 1, + title: "track a.b.1".to_string(), + }, artist: vec!["artist a.b.1".to_string()], quality: Quality { format: Format::Flac, @@ -60,8 +68,10 @@ macro_rules! collection { }, }, Track { - number: 2, - title: "track a.b.2".to_string(), + id: TrackId{ + number: 2, + title: "track a.b.2".to_string(), + }, artist: vec!["artist a.b.2".to_string()], quality: Quality { format: Format::Flac, @@ -84,8 +94,10 @@ macro_rules! collection { }, tracks: vec![ Track { - number: 1, - title: "track b.a.1".to_string(), + id: TrackId{ + number: 1, + title: "track b.a.1".to_string(), + }, artist: vec!["artist b.a.1".to_string()], quality: Quality { format: Format::Mp3, @@ -93,8 +105,10 @@ macro_rules! collection { }, }, Track { - number: 2, - title: "track b.a.2".to_string(), + id: TrackId{ + number: 2, + title: "track b.a.2".to_string(), + }, artist: vec![ "artist b.a.2.1".to_string(), "artist b.a.2.2".to_string(), @@ -113,8 +127,10 @@ macro_rules! collection { }, tracks: vec![ Track { - number: 1, - title: "track b.b.1".to_string(), + id: TrackId{ + number: 1, + title: "track b.b.1".to_string(), + }, artist: vec!["artist b.b.1".to_string()], quality: Quality { format: Format::Flac, @@ -122,8 +138,10 @@ macro_rules! collection { }, }, Track { - number: 2, - title: "track b.b.2".to_string(), + id: TrackId{ + number: 2, + title: "track b.b.2".to_string(), + }, artist: vec![ "artist b.b.2.1".to_string(), "artist b.b.2.2".to_string(), @@ -149,8 +167,10 @@ macro_rules! collection { }, tracks: vec![ Track { - number: 1, - title: "track c.a.1".to_string(), + id: TrackId{ + number: 1, + title: "track c.a.1".to_string(), + }, artist: vec!["artist c.a.1".to_string()], quality: Quality { format: Format::Mp3, @@ -158,8 +178,10 @@ macro_rules! collection { }, }, Track { - number: 2, - title: "track c.a.2".to_string(), + id: TrackId{ + number: 2, + title: "track c.a.2".to_string(), + }, artist: vec![ "artist c.a.2.1".to_string(), "artist c.a.2.2".to_string(), @@ -178,8 +200,10 @@ macro_rules! collection { }, tracks: vec![ Track { - number: 1, - title: "track c.b.1".to_string(), + id: TrackId{ + number: 1, + title: "track c.b.1".to_string(), + }, artist: vec!["artist c.b.1".to_string()], quality: Quality { format: Format::Flac, @@ -187,8 +211,10 @@ macro_rules! collection { }, }, Track { - number: 2, - title: "track c.b.2".to_string(), + id: TrackId{ + number: 2, + title: "track c.b.2".to_string(), + }, artist: vec![ "artist c.b.2.1".to_string(), "artist c.b.2.2".to_string(), diff --git a/src/tui/ui.rs b/src/tui/ui.rs index 4d0207e..5461278 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -404,7 +404,7 @@ impl<'a, 'b> TrackState<'a, 'b> { let list = List::new( tracks .iter() - .map(|id| ListItem::new(id.title.as_str())) + .map(|tr| ListItem::new(tr.id.title.as_str())) .collect::>(), ); @@ -415,9 +415,9 @@ impl<'a, 'b> TrackState<'a, 'b> { Artist: {}\n\ Quality: {}", track - .map(|t| t.number.to_string()) + .map(|t| t.id.number.to_string()) .unwrap_or_else(|| "".to_string()), - track.map(|t| t.title.as_str()).unwrap_or(""), + track.map(|t| t.id.title.as_str()).unwrap_or(""), track .map(|t| t.artist.join("; ")) .unwrap_or_else(|| "".to_string()), diff --git a/tests/files/database/database.json b/tests/files/database/database.json index 42cb67a..1c2d62c 100644 --- a/tests/files/database/database.json +++ b/tests/files/database/database.json @@ -1 +1 @@ -[{"id":{"name":"Аркона"},"albums":[{"id":{"year":2011,"title":"Slovo"},"tracks":[{"number":1,"title":"Az’","artist":["Аркона"],"quality":{"format":"Flac","bitrate":992}},{"number":2,"title":"Arkaim","artist":["Аркона"],"quality":{"format":"Flac","bitrate":1061}},{"number":3,"title":"Bol’no mne","artist":["Аркона"],"quality":{"format":"Flac","bitrate":1004}},{"number":4,"title":"Leshiy","artist":["Аркона"],"quality":{"format":"Flac","bitrate":1077}},{"number":5,"title":"Zakliatie","artist":["Аркона"],"quality":{"format":"Flac","bitrate":1041}},{"number":6,"title":"Predok","artist":["Аркона"],"quality":{"format":"Flac","bitrate":756}},{"number":7,"title":"Nikogda","artist":["Аркона"],"quality":{"format":"Flac","bitrate":1059}},{"number":8,"title":"Tam za tumanami","artist":["Аркона"],"quality":{"format":"Flac","bitrate":1023}},{"number":9,"title":"Potomok","artist":["Аркона"],"quality":{"format":"Flac","bitrate":838}},{"number":10,"title":"Slovo","artist":["Аркона"],"quality":{"format":"Flac","bitrate":1028}},{"number":11,"title":"Odna","artist":["Аркона"],"quality":{"format":"Flac","bitrate":991}},{"number":12,"title":"Vo moiom sadochke…","artist":["Аркона"],"quality":{"format":"Flac","bitrate":919}},{"number":13,"title":"Stenka na stenku","artist":["Аркона"],"quality":{"format":"Flac","bitrate":1039}},{"number":14,"title":"Zimushka","artist":["Аркона"],"quality":{"format":"Flac","bitrate":974}}]}]},{"id":{"name":"Eluveitie"},"albums":[{"id":{"year":2008,"title":"Slania"},"tracks":[{"number":1,"title":"Samon","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":953}},{"number":2,"title":"Primordial Breath","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1103}},{"number":3,"title":"Inis Mona","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1117}},{"number":4,"title":"Gray Sublime Archon","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1092}},{"number":5,"title":"Anagantios","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":923}},{"number":6,"title":"Bloodstained Ground","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1098}},{"number":7,"title":"The Somber Lay","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1068}},{"number":8,"title":"Slanias Song","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1098}},{"number":9,"title":"Giamonios","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":825}},{"number":10,"title":"Tarvos","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1115}},{"number":11,"title":"Calling the Rain","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1096}},{"number":12,"title":"Elembivos","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1059}}]},{"id":{"year":2004,"title":"Vên [re‐recorded]"},"tracks":[{"number":1,"title":"Verja Urit an Bitus","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":961}},{"number":2,"title":"Uis Elveti","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1067}},{"number":3,"title":"Ôrô","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":933}},{"number":4,"title":"Lament","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1083}},{"number":5,"title":"Druid","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1073}},{"number":6,"title":"Jêzaïg","artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1002}}]}]},{"id":{"name":"Frontside"},"albums":[{"id":{"year":2001,"title":"…nasze jest królestwo, potęga i chwała na wieki…"},"tracks":[{"number":1,"title":"Intro = Chaos","artist":["Frontside"],"quality":{"format":"Flac","bitrate":1024}},{"number":2,"title":"Modlitwa","artist":["Frontside"],"quality":{"format":"Flac","bitrate":1073}},{"number":3,"title":"Długa droga z piekła","artist":["Frontside"],"quality":{"format":"Flac","bitrate":1058}},{"number":4,"title":"Synowie ognia","artist":["Frontside"],"quality":{"format":"Flac","bitrate":1066}},{"number":5,"title":"1902","artist":["Frontside"],"quality":{"format":"Flac","bitrate":1074}},{"number":6,"title":"Krew za krew","artist":["Frontside"],"quality":{"format":"Flac","bitrate":1080}},{"number":7,"title":"Kulminacja","artist":["Frontside"],"quality":{"format":"Flac","bitrate":992}},{"number":8,"title":"Judasz","artist":["Frontside"],"quality":{"format":"Flac","bitrate":1018}},{"number":9,"title":"Więzy","artist":["Frontside"],"quality":{"format":"Flac","bitrate":1077}},{"number":10,"title":"Zagubione dusze","artist":["Frontside"],"quality":{"format":"Flac","bitrate":1033}},{"number":11,"title":"Linia życia","artist":["Frontside"],"quality":{"format":"Flac","bitrate":987}}]}]},{"id":{"name":"Heaven’s Basement"},"albums":[{"id":{"year":2011,"title":"Unbreakable"},"tracks":[{"number":1,"title":"Unbreakable","artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":208}},{"number":2,"title":"Guilt Trips and Sins","artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":205}},{"number":3,"title":"The Long Goodbye","artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":227}},{"number":4,"title":"Close Encounters","artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":213}},{"number":5,"title":"Paranoia","artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":218}},{"number":6,"title":"Let Me Out of Here","artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":207}},{"number":7,"title":"Leeches","artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":225}}]}]},{"id":{"name":"Metallica"},"albums":[{"id":{"year":1984,"title":"Ride the Lightning"},"tracks":[{"number":1,"title":"Fight Fire with Fire","artist":["Metallica"],"quality":{"format":"Flac","bitrate":954}},{"number":2,"title":"Ride the Lightning","artist":["Metallica"],"quality":{"format":"Flac","bitrate":951}},{"number":3,"title":"For Whom the Bell Tolls","artist":["Metallica"],"quality":{"format":"Flac","bitrate":889}},{"number":4,"title":"Fade to Black","artist":["Metallica"],"quality":{"format":"Flac","bitrate":939}},{"number":5,"title":"Trapped under Ice","artist":["Metallica"],"quality":{"format":"Flac","bitrate":955}},{"number":6,"title":"Escape","artist":["Metallica"],"quality":{"format":"Flac","bitrate":941}},{"number":7,"title":"Creeping Death","artist":["Metallica"],"quality":{"format":"Flac","bitrate":958}},{"number":8,"title":"The Call of Ktulu","artist":["Metallica"],"quality":{"format":"Flac","bitrate":888}}]},{"id":{"year":1999,"title":"S&M"},"tracks":[{"number":1,"title":"The Ecstasy of Gold","artist":["Metallica"],"quality":{"format":"Flac","bitrate":875}},{"number":2,"title":"The Call of Ktulu","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1030}},{"number":3,"title":"Master of Puppets","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1082}},{"number":4,"title":"Of Wolf and Man","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1115}},{"number":5,"title":"The Thing That Should Not Be","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1029}},{"number":6,"title":"Fuel","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1057}},{"number":7,"title":"The Memory Remains","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1080}},{"number":8,"title":"No Leaf Clover","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1004}},{"number":9,"title":"Hero of the Day","artist":["Metallica"],"quality":{"format":"Flac","bitrate":962}},{"number":10,"title":"Devil’s Dance","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1076}},{"number":11,"title":"Bleeding Me","artist":["Metallica"],"quality":{"format":"Flac","bitrate":993}},{"number":12,"title":"Nothing Else Matters","artist":["Metallica"],"quality":{"format":"Flac","bitrate":875}},{"number":13,"title":"Until It Sleeps","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1038}},{"number":14,"title":"For Whom the Bell Tolls","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1072}},{"number":15,"title":"−Human","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1029}},{"number":16,"title":"Wherever I May Roam","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1035}},{"number":17,"title":"Outlaw Torn","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1042}},{"number":18,"title":"Sad but True","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1082}},{"number":19,"title":"One","artist":["Metallica"],"quality":{"format":"Flac","bitrate":1017}},{"number":20,"title":"Enter Sandman","artist":["Metallica"],"quality":{"format":"Flac","bitrate":993}},{"number":21,"title":"Battery","artist":["Metallica"],"quality":{"format":"Flac","bitrate":967}}]}]}] \ No newline at end of file +[{"id":{"name":"Аркона"},"albums":[{"id":{"year":2011,"title":"Slovo"},"tracks":[{"id":{"number":1,"title":"Az’"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":992}},{"id":{"number":2,"title":"Arkaim"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":1061}},{"id":{"number":3,"title":"Bol’no mne"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":1004}},{"id":{"number":4,"title":"Leshiy"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":1077}},{"id":{"number":5,"title":"Zakliatie"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":1041}},{"id":{"number":6,"title":"Predok"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":756}},{"id":{"number":7,"title":"Nikogda"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":1059}},{"id":{"number":8,"title":"Tam za tumanami"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":1023}},{"id":{"number":9,"title":"Potomok"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":838}},{"id":{"number":10,"title":"Slovo"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":1028}},{"id":{"number":11,"title":"Odna"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":991}},{"id":{"number":12,"title":"Vo moiom sadochke…"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":919}},{"id":{"number":13,"title":"Stenka na stenku"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":1039}},{"id":{"number":14,"title":"Zimushka"},"artist":["Аркона"],"quality":{"format":"Flac","bitrate":974}}]}]},{"id":{"name":"Eluveitie"},"albums":[{"id":{"year":2008,"title":"Slania"},"tracks":[{"id":{"number":1,"title":"Samon"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":953}},{"id":{"number":2,"title":"Primordial Breath"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1103}},{"id":{"number":3,"title":"Inis Mona"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1117}},{"id":{"number":4,"title":"Gray Sublime Archon"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1092}},{"id":{"number":5,"title":"Anagantios"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":923}},{"id":{"number":6,"title":"Bloodstained Ground"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1098}},{"id":{"number":7,"title":"The Somber Lay"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1068}},{"id":{"number":8,"title":"Slanias Song"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1098}},{"id":{"number":9,"title":"Giamonios"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":825}},{"id":{"number":10,"title":"Tarvos"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1115}},{"id":{"number":11,"title":"Calling the Rain"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1096}},{"id":{"number":12,"title":"Elembivos"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1059}}]},{"id":{"year":2004,"title":"Vên [re‐recorded]"},"tracks":[{"id":{"number":1,"title":"Verja Urit an Bitus"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":961}},{"id":{"number":2,"title":"Uis Elveti"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1067}},{"id":{"number":3,"title":"Ôrô"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":933}},{"id":{"number":4,"title":"Lament"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1083}},{"id":{"number":5,"title":"Druid"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1073}},{"id":{"number":6,"title":"Jêzaïg"},"artist":["Eluveitie"],"quality":{"format":"Flac","bitrate":1002}}]}]},{"id":{"name":"Frontside"},"albums":[{"id":{"year":2001,"title":"…nasze jest królestwo, potęga i chwała na wieki…"},"tracks":[{"id":{"number":1,"title":"Intro = Chaos"},"artist":["Frontside"],"quality":{"format":"Flac","bitrate":1024}},{"id":{"number":2,"title":"Modlitwa"},"artist":["Frontside"],"quality":{"format":"Flac","bitrate":1073}},{"id":{"number":3,"title":"Długa droga z piekła"},"artist":["Frontside"],"quality":{"format":"Flac","bitrate":1058}},{"id":{"number":4,"title":"Synowie ognia"},"artist":["Frontside"],"quality":{"format":"Flac","bitrate":1066}},{"id":{"number":5,"title":"1902"},"artist":["Frontside"],"quality":{"format":"Flac","bitrate":1074}},{"id":{"number":6,"title":"Krew za krew"},"artist":["Frontside"],"quality":{"format":"Flac","bitrate":1080}},{"id":{"number":7,"title":"Kulminacja"},"artist":["Frontside"],"quality":{"format":"Flac","bitrate":992}},{"id":{"number":8,"title":"Judasz"},"artist":["Frontside"],"quality":{"format":"Flac","bitrate":1018}},{"id":{"number":9,"title":"Więzy"},"artist":["Frontside"],"quality":{"format":"Flac","bitrate":1077}},{"id":{"number":10,"title":"Zagubione dusze"},"artist":["Frontside"],"quality":{"format":"Flac","bitrate":1033}},{"id":{"number":11,"title":"Linia życia"},"artist":["Frontside"],"quality":{"format":"Flac","bitrate":987}}]}]},{"id":{"name":"Heaven’s Basement"},"albums":[{"id":{"year":2011,"title":"Unbreakable"},"tracks":[{"id":{"number":1,"title":"Unbreakable"},"artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":208}},{"id":{"number":2,"title":"Guilt Trips and Sins"},"artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":205}},{"id":{"number":3,"title":"The Long Goodbye"},"artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":227}},{"id":{"number":4,"title":"Close Encounters"},"artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":213}},{"id":{"number":5,"title":"Paranoia"},"artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":218}},{"id":{"number":6,"title":"Let Me Out of Here"},"artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":207}},{"id":{"number":7,"title":"Leeches"},"artist":["Heaven’s Basement"],"quality":{"format":"Mp3","bitrate":225}}]}]},{"id":{"name":"Metallica"},"albums":[{"id":{"year":1984,"title":"Ride the Lightning"},"tracks":[{"id":{"number":1,"title":"Fight Fire with Fire"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":954}},{"id":{"number":2,"title":"Ride the Lightning"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":951}},{"id":{"number":3,"title":"For Whom the Bell Tolls"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":889}},{"id":{"number":4,"title":"Fade to Black"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":939}},{"id":{"number":5,"title":"Trapped under Ice"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":955}},{"id":{"number":6,"title":"Escape"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":941}},{"id":{"number":7,"title":"Creeping Death"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":958}},{"id":{"number":8,"title":"The Call of Ktulu"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":888}}]},{"id":{"year":1999,"title":"S&M"},"tracks":[{"id":{"number":1,"title":"The Ecstasy of Gold"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":875}},{"id":{"number":2,"title":"The Call of Ktulu"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1030}},{"id":{"number":3,"title":"Master of Puppets"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1082}},{"id":{"number":4,"title":"Of Wolf and Man"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1115}},{"id":{"number":5,"title":"The Thing That Should Not Be"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1029}},{"id":{"number":6,"title":"Fuel"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1057}},{"id":{"number":7,"title":"The Memory Remains"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1080}},{"id":{"number":8,"title":"No Leaf Clover"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1004}},{"id":{"number":9,"title":"Hero of the Day"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":962}},{"id":{"number":10,"title":"Devil’s Dance"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1076}},{"id":{"number":11,"title":"Bleeding Me"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":993}},{"id":{"number":12,"title":"Nothing Else Matters"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":875}},{"id":{"number":13,"title":"Until It Sleeps"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1038}},{"id":{"number":14,"title":"For Whom the Bell Tolls"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1072}},{"id":{"number":15,"title":"−Human"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1029}},{"id":{"number":16,"title":"Wherever I May Roam"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1035}},{"id":{"number":17,"title":"Outlaw Torn"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1042}},{"id":{"number":18,"title":"Sad but True"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1082}},{"id":{"number":19,"title":"One"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":1017}},{"id":{"number":20,"title":"Enter Sandman"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":993}},{"id":{"number":21,"title":"Battery"},"artist":["Metallica"],"quality":{"format":"Flac","bitrate":967}}]}]}] \ No newline at end of file diff --git a/tests/lib.rs b/tests/lib.rs index b92eb2b..de4c371 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,7 +1,7 @@ mod database; mod library; -use musichoard::{Album, AlbumId, Artist, ArtistId, Format, Quality, Track}; +use musichoard::{Album, AlbumId, Artist, ArtistId, Format, Quality, Track, TrackId}; use once_cell::sync::Lazy; static COLLECTION: Lazy> = Lazy::new(|| { @@ -17,8 +17,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, tracks: vec![ Track { - number: 01, - title: String::from("Az’"), + id: TrackId { + number: 01, + title: String::from("Az’"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -26,8 +28,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 02, - title: String::from("Arkaim"), + id: TrackId { + number: 02, + title: String::from("Arkaim"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -35,8 +39,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 03, - title: String::from("Bol’no mne"), + id: TrackId { + number: 03, + title: String::from("Bol’no mne"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -44,8 +50,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 04, - title: String::from("Leshiy"), + id: TrackId{ + number: 04, + title: String::from("Leshiy"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -53,8 +61,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 05, - title: String::from("Zakliatie"), + id: TrackId{ + number: 05, + title: String::from("Zakliatie"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -62,8 +72,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 06, - title: String::from("Predok"), + id: TrackId{ + number: 06, + title: String::from("Predok"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -71,8 +83,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 07, - title: String::from("Nikogda"), + id: TrackId{ + number: 07, + title: String::from("Nikogda"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -80,8 +94,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 08, - title: String::from("Tam za tumanami"), + id: TrackId{ + number: 08, + title: String::from("Tam za tumanami"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -89,8 +105,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 09, - title: String::from("Potomok"), + id: TrackId{ + number: 09, + title: String::from("Potomok"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -98,8 +116,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 10, - title: String::from("Slovo"), + id: TrackId{ + number: 10, + title: String::from("Slovo"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -107,8 +127,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 11, - title: String::from("Odna"), + id: TrackId{ + number: 11, + title: String::from("Odna"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -116,8 +138,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 12, - title: String::from("Vo moiom sadochke…"), + id: TrackId{ + number: 12, + title: String::from("Vo moiom sadochke…"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -125,8 +149,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 13, - title: String::from("Stenka na stenku"), + id: TrackId{ + number: 13, + title: String::from("Stenka na stenku"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -134,8 +160,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 14, - title: String::from("Zimushka"), + id: TrackId{ + number: 14, + title: String::from("Zimushka"), + }, artist: vec![String::from("Аркона")], quality: Quality { format: Format::Flac, @@ -157,8 +185,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, tracks: vec![ Track { - number: 01, - title: String::from("Samon"), + id: TrackId{ + number: 01, + title: String::from("Samon"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -166,8 +196,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 02, - title: String::from("Primordial Breath"), + id: TrackId{ + number: 02, + title: String::from("Primordial Breath"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -175,8 +207,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 03, - title: String::from("Inis Mona"), + id: TrackId{ + number: 03, + title: String::from("Inis Mona"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -184,8 +218,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 04, - title: String::from("Gray Sublime Archon"), + id: TrackId{ + number: 04, + title: String::from("Gray Sublime Archon"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -193,8 +229,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 05, - title: String::from("Anagantios"), + id: TrackId{ + number: 05, + title: String::from("Anagantios"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -202,8 +240,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 06, - title: String::from("Bloodstained Ground"), + id: TrackId{ + number: 06, + title: String::from("Bloodstained Ground"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -211,8 +251,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 07, - title: String::from("The Somber Lay"), + id: TrackId{ + number: 07, + title: String::from("The Somber Lay"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -220,8 +262,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 08, - title: String::from("Slanias Song"), + id: TrackId{ + number: 08, + title: String::from("Slanias Song"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -229,8 +273,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 09, - title: String::from("Giamonios"), + id: TrackId{ + number: 09, + title: String::from("Giamonios"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -238,8 +284,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 10, - title: String::from("Tarvos"), + id: TrackId{ + number: 10, + title: String::from("Tarvos"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -247,8 +295,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 11, - title: String::from("Calling the Rain"), + id: TrackId{ + number: 11, + title: String::from("Calling the Rain"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -256,8 +306,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 12, - title: String::from("Elembivos"), + id: TrackId{ + number: 12, + title: String::from("Elembivos"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -273,8 +325,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, tracks: vec![ Track { - number: 01, - title: String::from("Verja Urit an Bitus"), + id: TrackId{ + number: 01, + title: String::from("Verja Urit an Bitus"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -282,8 +336,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 02, - title: String::from("Uis Elveti"), + id: TrackId{ + number: 02, + title: String::from("Uis Elveti"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -291,8 +347,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 03, - title: String::from("Ôrô"), + id: TrackId{ + number: 03, + title: String::from("Ôrô"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -300,8 +358,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 04, - title: String::from("Lament"), + id: TrackId{ + number: 04, + title: String::from("Lament"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -309,8 +369,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 05, - title: String::from("Druid"), + id: TrackId{ + number: 05, + title: String::from("Druid"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -318,8 +380,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 06, - title: String::from("Jêzaïg"), + id: TrackId{ + number: 06, + title: String::from("Jêzaïg"), + }, artist: vec![String::from("Eluveitie")], quality: Quality { format: Format::Flac, @@ -341,8 +405,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, tracks: vec![ Track { - number: 01, - title: String::from("Intro = Chaos"), + id: TrackId{ + number: 01, + title: String::from("Intro = Chaos"), + }, artist: vec![String::from("Frontside")], quality: Quality { format: Format::Flac, @@ -350,8 +416,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 02, - title: String::from("Modlitwa"), + id: TrackId{ + number: 02, + title: String::from("Modlitwa"), + }, artist: vec![String::from("Frontside")], quality: Quality { format: Format::Flac, @@ -359,8 +427,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 03, - title: String::from("Długa droga z piekła"), + id: TrackId{ + number: 03, + title: String::from("Długa droga z piekła"), + }, artist: vec![String::from("Frontside")], quality: Quality { format: Format::Flac, @@ -368,8 +438,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 04, - title: String::from("Synowie ognia"), + id: TrackId{ + number: 04, + title: String::from("Synowie ognia"), + }, artist: vec![String::from("Frontside")], quality: Quality { format: Format::Flac, @@ -377,8 +449,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 05, - title: String::from("1902"), + id: TrackId{ + number: 05, + title: String::from("1902"), + }, artist: vec![String::from("Frontside")], quality: Quality { format: Format::Flac, @@ -386,8 +460,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 06, - title: String::from("Krew za krew"), + id: TrackId{ + number: 06, + title: String::from("Krew za krew"), + }, artist: vec![String::from("Frontside")], quality: Quality { format: Format::Flac, @@ -395,8 +471,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 07, - title: String::from("Kulminacja"), + id: TrackId{ + number: 07, + title: String::from("Kulminacja"), + }, artist: vec![String::from("Frontside")], quality: Quality { format: Format::Flac, @@ -404,8 +482,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 08, - title: String::from("Judasz"), + id: TrackId{ + number: 08, + title: String::from("Judasz"), + }, artist: vec![String::from("Frontside")], quality: Quality { format: Format::Flac, @@ -413,8 +493,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 09, - title: String::from("Więzy"), + id: TrackId{ + number: 09, + title: String::from("Więzy"), + }, artist: vec![String::from("Frontside")], quality: Quality { format: Format::Flac, @@ -422,8 +504,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 10, - title: String::from("Zagubione dusze"), + id: TrackId{ + number: 10, + title: String::from("Zagubione dusze"), + }, artist: vec![String::from("Frontside")], quality: Quality { format: Format::Flac, @@ -431,8 +515,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 11, - title: String::from("Linia życia"), + id: TrackId{ + number: 11, + title: String::from("Linia życia"), + }, artist: vec![String::from("Frontside")], quality: Quality { format: Format::Flac, @@ -453,8 +539,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, tracks: vec![ Track { - number: 01, - title: String::from("Unbreakable"), + id: TrackId{ + number: 01, + title: String::from("Unbreakable"), + }, artist: vec![String::from("Heaven’s Basement")], quality: Quality { format: Format::Mp3, @@ -462,8 +550,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 02, - title: String::from("Guilt Trips and Sins"), + id: TrackId{ + number: 02, + title: String::from("Guilt Trips and Sins"), + }, artist: vec![String::from("Heaven’s Basement")], quality: Quality { format: Format::Mp3, @@ -471,8 +561,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 03, - title: String::from("The Long Goodbye"), + id: TrackId{ + number: 03, + title: String::from("The Long Goodbye"), + }, artist: vec![String::from("Heaven’s Basement")], quality: Quality { format: Format::Mp3, @@ -480,8 +572,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 04, - title: String::from("Close Encounters"), + id: TrackId{ + number: 04, + title: String::from("Close Encounters"), + }, artist: vec![String::from("Heaven’s Basement")], quality: Quality { format: Format::Mp3, @@ -489,8 +583,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 05, - title: String::from("Paranoia"), + id: TrackId{ + number: 05, + title: String::from("Paranoia"), + }, artist: vec![String::from("Heaven’s Basement")], quality: Quality { format: Format::Mp3, @@ -498,8 +594,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 06, - title: String::from("Let Me Out of Here"), + id: TrackId{ + number: 06, + title: String::from("Let Me Out of Here"), + }, artist: vec![String::from("Heaven’s Basement")], quality: Quality { format: Format::Mp3, @@ -507,8 +605,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 07, - title: String::from("Leeches"), + id: TrackId{ + number: 07, + title: String::from("Leeches"), + }, artist: vec![String::from("Heaven’s Basement")], quality: Quality { format: Format::Mp3, @@ -530,8 +630,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, tracks: vec![ Track { - number: 01, - title: String::from("Fight Fire with Fire"), + id: TrackId{ + number: 01, + title: String::from("Fight Fire with Fire"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -539,8 +641,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 02, - title: String::from("Ride the Lightning"), + id: TrackId{ + number: 02, + title: String::from("Ride the Lightning"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -548,8 +652,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 03, - title: String::from("For Whom the Bell Tolls"), + id: TrackId{ + number: 03, + title: String::from("For Whom the Bell Tolls"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -557,8 +663,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 04, - title: String::from("Fade to Black"), + id: TrackId{ + number: 04, + title: String::from("Fade to Black"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -566,8 +674,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 05, - title: String::from("Trapped under Ice"), + id: TrackId{ + number: 05, + title: String::from("Trapped under Ice"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -575,8 +685,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 06, - title: String::from("Escape"), + id: TrackId{ + number: 06, + title: String::from("Escape"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -584,8 +696,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 07, - title: String::from("Creeping Death"), + id: TrackId{ + number: 07, + title: String::from("Creeping Death"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -593,8 +707,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 08, - title: String::from("The Call of Ktulu"), + id: TrackId{ + number: 08, + title: String::from("The Call of Ktulu"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -610,8 +726,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, tracks: vec![ Track { - number: 01, - title: String::from("The Ecstasy of Gold"), + id: TrackId{ + number: 01, + title: String::from("The Ecstasy of Gold"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -619,8 +737,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 02, - title: String::from("The Call of Ktulu"), + id: TrackId{ + number: 02, + title: String::from("The Call of Ktulu"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -628,8 +748,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 03, - title: String::from("Master of Puppets"), + id: TrackId{ + number: 03, + title: String::from("Master of Puppets"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -637,8 +759,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 04, - title: String::from("Of Wolf and Man"), + id: TrackId{ + number: 04, + title: String::from("Of Wolf and Man"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -646,8 +770,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 05, - title: String::from("The Thing That Should Not Be"), + id: TrackId{ + number: 05, + title: String::from("The Thing That Should Not Be"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -655,8 +781,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 06, - title: String::from("Fuel"), + id: TrackId{ + number: 06, + title: String::from("Fuel"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -664,8 +792,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 07, - title: String::from("The Memory Remains"), + id: TrackId{ + number: 07, + title: String::from("The Memory Remains"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -673,8 +803,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 08, - title: String::from("No Leaf Clover"), + id: TrackId{ + number: 08, + title: String::from("No Leaf Clover"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -682,8 +814,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 09, - title: String::from("Hero of the Day"), + id: TrackId{ + number: 09, + title: String::from("Hero of the Day"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -691,8 +825,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 10, - title: String::from("Devil’s Dance"), + id: TrackId{ + number: 10, + title: String::from("Devil’s Dance"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -700,8 +836,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 11, - title: String::from("Bleeding Me"), + id: TrackId{ + number: 11, + title: String::from("Bleeding Me"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -709,8 +847,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 12, - title: String::from("Nothing Else Matters"), + id: TrackId{ + number: 12, + title: String::from("Nothing Else Matters"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -718,8 +858,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 13, - title: String::from("Until It Sleeps"), + id: TrackId{ + number: 13, + title: String::from("Until It Sleeps"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -727,8 +869,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 14, - title: String::from("For Whom the Bell Tolls"), + id: TrackId{ + number: 14, + title: String::from("For Whom the Bell Tolls"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -736,8 +880,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 15, - title: String::from("−Human"), + id: TrackId{ + number: 15, + title: String::from("−Human"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -745,8 +891,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 16, - title: String::from("Wherever I May Roam"), + id: TrackId{ + number: 16, + title: String::from("Wherever I May Roam"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -754,8 +902,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 17, - title: String::from("Outlaw Torn"), + id: TrackId{ + number: 17, + title: String::from("Outlaw Torn"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -763,8 +913,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 18, - title: String::from("Sad but True"), + id: TrackId{ + number: 18, + title: String::from("Sad but True"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -772,8 +924,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 19, - title: String::from("One"), + id: TrackId{ + number: 19, + title: String::from("One"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -781,8 +935,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 20, - title: String::from("Enter Sandman"), + id: TrackId{ + number: 20, + title: String::from("Enter Sandman"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, @@ -790,8 +946,10 @@ static COLLECTION: Lazy> = Lazy::new(|| { }, }, Track { - number: 21, - title: String::from("Battery"), + id: TrackId{ + number: 21, + title: String::from("Battery"), + }, artist: vec![String::from("Metallica")], quality: Quality { format: Format::Flac, diff --git a/tests/library/beets.rs b/tests/library/beets.rs index 57cad1d..6cd0f5c 100644 --- a/tests/library/beets.rs +++ b/tests/library/beets.rs @@ -41,8 +41,8 @@ fn artist_to_items(artist: &Artist) -> Vec { album_artist: artist.id.name.clone(), album_year: album.id.year, album_title: album.id.title.clone(), - track_number: track.number, - track_title: track.title.clone(), + track_number: track.id.number, + track_title: track.id.title.clone(), track_artist: track.artist.clone(), track_format: track.quality.format, track_bitrate: track.quality.bitrate,