Change Quality enum to a struct #66

Merged
wojtek merged 1 commits from 65---change-quality-enum-to-a-struct into main 2023-05-11 21:45:23 +02:00
7 changed files with 403 additions and 119 deletions

View File

@ -61,7 +61,7 @@ mod tests {
use super::*; use super::*;
use crate::{tests::COLLECTION, Artist, ArtistId, Quality}; use crate::{tests::COLLECTION, Artist, ArtistId, Format};
fn artist_to_json(artist: &Artist) -> String { fn artist_to_json(artist: &Artist) -> String {
let album_artist = &artist.id.name; let album_artist = &artist.id.name;
@ -81,21 +81,18 @@ mod tests {
track_artist.push(format!("\"{artist}\"")) track_artist.push(format!("\"{artist}\""))
} }
let track_artist = track_artist.join(","); let track_artist = track_artist.join(",");
let track_format = match track.quality.format {
let quality_field = match track.quality { Format::Flac => stringify!(Flac),
Quality::Flac => format!("\"quality\":\"{format}\"", format = stringify!(Flac)), Format::Mp3 => stringify!(Mp3),
Quality::Mp3(bitrate) => format!(
"\"quality\":{{\"{format}\":{bitrate}}}",
format = stringify!(Mp3)
),
}; };
let track_bitrate = track.quality.bitrate;
tracks.push(format!( tracks.push(format!(
"{{\ "{{\
\"number\":{track_number},\ \"number\":{track_number},\
\"title\":\"{track_title}\",\ \"title\":\"{track_title}\",\
\"artist\":[{track_artist}],\ \"artist\":[{track_artist}],\
{quality_field}\ \"quality\":{{\"format\":\"{track_format}\",\"bitrate\":{track_bitrate}}}\
}}" }}"
)); ));
} }

View File

@ -14,10 +14,17 @@ use uuid::Uuid;
pub type Mbid = Uuid; pub type Mbid = Uuid;
/// The track file format. /// The track file format.
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub enum Quality { pub enum Format {
Flac, Flac,
Mp3(u32), Mp3,
}
/// The track quality. Combines format and bitrate information.
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct Quality {
pub format: Format,
pub bitrate: u32,
} }
/// A single track on an album. /// A single track on an album.

View File

@ -9,7 +9,7 @@ use std::{
#[cfg(test)] #[cfg(test)]
use mockall::automock; use mockall::automock;
use crate::{Album, AlbumId, Artist, ArtistId, Quality, Track}; use crate::{Album, AlbumId, Artist, ArtistId, Format, Quality, Track};
use super::{Error, Field, ILibrary, Query}; use super::{Error, Field, ILibrary, Query};
@ -153,11 +153,14 @@ impl<BLE: IBeetsLibraryExecutor> ILibraryPrivate for BeetsLibrary<BLE> {
number: track_number, number: track_number,
title: track_title, title: track_title,
artist: track_artist.split("; ").map(|s| s.to_owned()).collect(), artist: track_artist.split("; ").map(|s| s.to_owned()).collect(),
quality: match track_format.as_ref() { quality: Quality {
TRACK_FORMAT_FLAC => Quality::Flac, format: match track_format.as_ref() {
TRACK_FORMAT_MP3 => Quality::Mp3(track_bitrate), TRACK_FORMAT_FLAC => Format::Flac,
TRACK_FORMAT_MP3 => Format::Mp3,
_ => return Err(Error::Invalid(line.to_string())), _ => return Err(Error::Invalid(line.to_string())),
}, },
bitrate: track_bitrate,
},
}; };
let artist = if album_ids.contains_key(&artist_id) { let artist = if album_ids.contains_key(&artist_id) {
@ -222,10 +225,11 @@ mod tests {
let track_number = &track.number; let track_number = &track.number;
let track_title = &track.title; let track_title = &track.title;
let track_artist = &track.artist.join("; "); let track_artist = &track.artist.join("; ");
let (track_format, track_bitrate) = match track.quality { let track_format = match track.quality.format {
Quality::Flac => (TRACK_FORMAT_FLAC, 1411), Format::Flac => TRACK_FORMAT_FLAC,
Quality::Mp3(bitrate) => (TRACK_FORMAT_MP3, bitrate), Format::Mp3 => TRACK_FORMAT_MP3,
}; };
let track_bitrate = track.quality.bitrate;
strings.push(format!( strings.push(format!(
"{album_artist}{0}{album_year}{0}{album_title}{0}\ "{album_artist}{0}{album_year}{0}{album_title}{0}\

View File

@ -16,7 +16,10 @@ macro_rules! collection {
number: 1, number: 1,
title: "track a.a.1".to_string(), title: "track a.a.1".to_string(),
artist: vec!["artist a.a.1".to_string()], artist: vec!["artist a.a.1".to_string()],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 992,
},
}, },
Track { Track {
number: 2, number: 2,
@ -25,13 +28,19 @@ macro_rules! collection {
"artist a.a.2.1".to_string(), "artist a.a.2.1".to_string(),
"artist a.a.2.2".to_string(), "artist a.a.2.2".to_string(),
], ],
quality: Quality::Mp3(320), quality: Quality {
format: Format::Mp3,
bitrate: 320,
},
}, },
Track { Track {
number: 3, number: 3,
title: "track a.a.3".to_string(), title: "track a.a.3".to_string(),
artist: vec!["artist a.a.3".to_string()], artist: vec!["artist a.a.3".to_string()],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1061,
},
}, },
], ],
}, },
@ -45,13 +54,19 @@ macro_rules! collection {
number: 1, number: 1,
title: "track a.b.1".to_string(), title: "track a.b.1".to_string(),
artist: vec!["artist a.b.1".to_string()], artist: vec!["artist a.b.1".to_string()],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1004,
},
}, },
Track { Track {
number: 2, number: 2,
title: "track a.b.2".to_string(), title: "track a.b.2".to_string(),
artist: vec!["artist a.b.2".to_string()], artist: vec!["artist a.b.2".to_string()],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1077,
},
}, },
], ],
}, },
@ -72,7 +87,10 @@ macro_rules! collection {
number: 1, number: 1,
title: "track b.a.1".to_string(), title: "track b.a.1".to_string(),
artist: vec!["artist b.a.1".to_string()], artist: vec!["artist b.a.1".to_string()],
quality: Quality::Mp3(190), quality: Quality {
format: Format::Mp3,
bitrate: 190,
},
}, },
Track { Track {
number: 2, number: 2,
@ -81,7 +99,10 @@ macro_rules! collection {
"artist b.a.2.1".to_string(), "artist b.a.2.1".to_string(),
"artist b.a.2.2".to_string(), "artist b.a.2.2".to_string(),
], ],
quality: Quality::Mp3(120), quality: Quality {
format: Format::Mp3,
bitrate: 120,
},
}, },
], ],
}, },
@ -95,7 +116,10 @@ macro_rules! collection {
number: 1, number: 1,
title: "track b.b.1".to_string(), title: "track b.b.1".to_string(),
artist: vec!["artist b.b.1".to_string()], artist: vec!["artist b.b.1".to_string()],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1077,
},
}, },
Track { Track {
number: 2, number: 2,
@ -104,7 +128,10 @@ macro_rules! collection {
"artist b.b.2.1".to_string(), "artist b.b.2.1".to_string(),
"artist b.b.2.2".to_string(), "artist b.b.2.2".to_string(),
], ],
quality: Quality::Mp3(320), quality: Quality {
format: Format::Mp3,
bitrate: 320,
},
}, },
], ],
}, },
@ -125,7 +152,10 @@ macro_rules! collection {
number: 1, number: 1,
title: "track c.a.1".to_string(), title: "track c.a.1".to_string(),
artist: vec!["artist c.a.1".to_string()], artist: vec!["artist c.a.1".to_string()],
quality: Quality::Mp3(320), quality: Quality {
format: Format::Mp3,
bitrate: 320,
},
}, },
Track { Track {
number: 2, number: 2,
@ -134,7 +164,10 @@ macro_rules! collection {
"artist c.a.2.1".to_string(), "artist c.a.2.1".to_string(),
"artist c.a.2.2".to_string(), "artist c.a.2.2".to_string(),
], ],
quality: Quality::Mp3(120), quality: Quality {
format: Format::Mp3,
bitrate: 120,
},
}, },
], ],
}, },
@ -148,7 +181,10 @@ macro_rules! collection {
number: 1, number: 1,
title: "track c.b.1".to_string(), title: "track c.b.1".to_string(),
artist: vec!["artist c.b.1".to_string()], artist: vec!["artist c.b.1".to_string()],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1041,
},
}, },
Track { Track {
number: 2, number: 2,
@ -157,7 +193,10 @@ macro_rules! collection {
"artist c.b.2.1".to_string(), "artist c.b.2.1".to_string(),
"artist c.b.2.2".to_string(), "artist c.b.2.2".to_string(),
], ],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 756,
},
}, },
], ],
}, },

View File

@ -1,4 +1,4 @@
use musichoard::{Album, Artist, Collection, Quality, Track}; use musichoard::{Album, Artist, Collection, Format, Track};
use ratatui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
@ -413,7 +413,7 @@ impl<'a, 'b> TrackState<'a, 'b> {
"Track: {}\n\ "Track: {}\n\
Title: {}\n\ Title: {}\n\
Artist: {}\n\ Artist: {}\n\
Format: {}", Quality: {}",
track track
.map(|t| t.number.to_string()) .map(|t| t.number.to_string())
.unwrap_or_else(|| "".to_string()), .unwrap_or_else(|| "".to_string()),
@ -422,9 +422,9 @@ impl<'a, 'b> TrackState<'a, 'b> {
.map(|t| t.artist.join("; ")) .map(|t| t.artist.join("; "))
.unwrap_or_else(|| "".to_string()), .unwrap_or_else(|| "".to_string()),
track track
.map(|t| match t.quality { .map(|t| match t.quality.format {
Quality::Flac => "FLAC".to_string(), Format::Flac => "FLAC".to_string(),
Quality::Mp3(bitrate) => format!("MP3 {bitrate}"), Format::Mp3 => format!("MP3 {}kbps", t.quality.bitrate),
}) })
.unwrap_or_else(|| "".to_string()), .unwrap_or_else(|| "".to_string()),
)); ));

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
mod database; mod database;
mod library; mod library;
use musichoard::{Album, AlbumId, Artist, ArtistId, Quality, Track}; use musichoard::{Album, AlbumId, Artist, ArtistId, Format, Quality, Track};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| { static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
@ -20,85 +20,127 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
number: 01, number: 01,
title: String::from("Az"), title: String::from("Az"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 992,
},
}, },
Track { Track {
number: 02, number: 02,
title: String::from("Arkaim"), title: String::from("Arkaim"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1061,
},
}, },
Track { Track {
number: 03, number: 03,
title: String::from("Bolno mne"), title: String::from("Bolno mne"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1004,
},
}, },
Track { Track {
number: 04, number: 04,
title: String::from("Leshiy"), title: String::from("Leshiy"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1077,
},
}, },
Track { Track {
number: 05, number: 05,
title: String::from("Zakliatie"), title: String::from("Zakliatie"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1041,
},
}, },
Track { Track {
number: 06, number: 06,
title: String::from("Predok"), title: String::from("Predok"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 756,
},
}, },
Track { Track {
number: 07, number: 07,
title: String::from("Nikogda"), title: String::from("Nikogda"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1059,
},
}, },
Track { Track {
number: 08, number: 08,
title: String::from("Tam za tumanami"), title: String::from("Tam za tumanami"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1023,
},
}, },
Track { Track {
number: 09, number: 09,
title: String::from("Potomok"), title: String::from("Potomok"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 838,
},
}, },
Track { Track {
number: 10, number: 10,
title: String::from("Slovo"), title: String::from("Slovo"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1028,
},
}, },
Track { Track {
number: 11, number: 11,
title: String::from("Odna"), title: String::from("Odna"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 991,
},
}, },
Track { Track {
number: 12, number: 12,
title: String::from("Vo moiom sadochke…"), title: String::from("Vo moiom sadochke…"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 919,
},
}, },
Track { Track {
number: 13, number: 13,
title: String::from("Stenka na stenku"), title: String::from("Stenka na stenku"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1039,
},
}, },
Track { Track {
number: 14, number: 14,
title: String::from("Zimushka"), title: String::from("Zimushka"),
artist: vec![String::from("Аркона")], artist: vec![String::from("Аркона")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 974,
},
}, },
], ],
}], }],
@ -118,73 +160,109 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
number: 01, number: 01,
title: String::from("Samon"), title: String::from("Samon"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 953,
},
}, },
Track { Track {
number: 02, number: 02,
title: String::from("Primordial Breath"), title: String::from("Primordial Breath"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1103,
},
}, },
Track { Track {
number: 03, number: 03,
title: String::from("Inis Mona"), title: String::from("Inis Mona"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1117,
},
}, },
Track { Track {
number: 04, number: 04,
title: String::from("Gray Sublime Archon"), title: String::from("Gray Sublime Archon"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1092,
},
}, },
Track { Track {
number: 05, number: 05,
title: String::from("Anagantios"), title: String::from("Anagantios"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 923,
},
}, },
Track { Track {
number: 06, number: 06,
title: String::from("Bloodstained Ground"), title: String::from("Bloodstained Ground"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1098,
},
}, },
Track { Track {
number: 07, number: 07,
title: String::from("The Somber Lay"), title: String::from("The Somber Lay"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1068,
},
}, },
Track { Track {
number: 08, number: 08,
title: String::from("Slanias Song"), title: String::from("Slanias Song"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1098,
},
}, },
Track { Track {
number: 09, number: 09,
title: String::from("Giamonios"), title: String::from("Giamonios"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 825,
},
}, },
Track { Track {
number: 10, number: 10,
title: String::from("Tarvos"), title: String::from("Tarvos"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1115,
},
}, },
Track { Track {
number: 11, number: 11,
title: String::from("Calling the Rain"), title: String::from("Calling the Rain"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1096,
},
}, },
Track { Track {
number: 12, number: 12,
title: String::from("Elembivos"), title: String::from("Elembivos"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1059,
},
}, },
], ],
}, },
@ -198,37 +276,55 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
number: 01, number: 01,
title: String::from("Verja Urit an Bitus"), title: String::from("Verja Urit an Bitus"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 961,
},
}, },
Track { Track {
number: 02, number: 02,
title: String::from("Uis Elveti"), title: String::from("Uis Elveti"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1067,
},
}, },
Track { Track {
number: 03, number: 03,
title: String::from("Ôrô"), title: String::from("Ôrô"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 933,
},
}, },
Track { Track {
number: 04, number: 04,
title: String::from("Lament"), title: String::from("Lament"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1083,
},
}, },
Track { Track {
number: 05, number: 05,
title: String::from("Druid"), title: String::from("Druid"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1073,
},
}, },
Track { Track {
number: 06, number: 06,
title: String::from("Jêzaïg"), title: String::from("Jêzaïg"),
artist: vec![String::from("Eluveitie")], artist: vec![String::from("Eluveitie")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1002,
},
}, },
], ],
}, },
@ -248,67 +344,100 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
number: 01, number: 01,
title: String::from("Intro = Chaos"), title: String::from("Intro = Chaos"),
artist: vec![String::from("Frontside")], artist: vec![String::from("Frontside")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1024,
},
}, },
Track { Track {
number: 02, number: 02,
title: String::from("Modlitwa"), title: String::from("Modlitwa"),
artist: vec![String::from("Frontside")], artist: vec![String::from("Frontside")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1073,
},
}, },
Track { Track {
number: 03, number: 03,
title: String::from("Długa droga z piekła"), title: String::from("Długa droga z piekła"),
artist: vec![String::from("Frontside")], artist: vec![String::from("Frontside")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1058,
},
}, },
Track { Track {
number: 04, number: 04,
title: String::from("Synowie ognia"), title: String::from("Synowie ognia"),
artist: vec![String::from("Frontside")], artist: vec![String::from("Frontside")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1066,
},
}, },
Track { Track {
number: 05, number: 05,
title: String::from("1902"), title: String::from("1902"),
artist: vec![String::from("Frontside")], artist: vec![String::from("Frontside")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1074,
},
}, },
Track { Track {
number: 06, number: 06,
title: String::from("Krew za krew"), title: String::from("Krew za krew"),
artist: vec![String::from("Frontside")], artist: vec![String::from("Frontside")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1080,
},
}, },
Track { Track {
number: 07, number: 07,
title: String::from("Kulminacja"), title: String::from("Kulminacja"),
artist: vec![String::from("Frontside")], artist: vec![String::from("Frontside")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 992,
},
}, },
Track { Track {
number: 08, number: 08,
title: String::from("Judasz"), title: String::from("Judasz"),
artist: vec![String::from("Frontside")], artist: vec![String::from("Frontside")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1018,
},
}, },
Track { Track {
number: 09, number: 09,
title: String::from("Więzy"), title: String::from("Więzy"),
artist: vec![String::from("Frontside")], artist: vec![String::from("Frontside")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1077,
},
}, },
Track { Track {
number: 10, number: 10,
title: String::from("Zagubione dusze"), title: String::from("Zagubione dusze"),
artist: vec![String::from("Frontside")], artist: vec![String::from("Frontside")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1033,
},
}, },
Track { Track {
number: 11, number: 11,
title: String::from("Linia życia"), title: String::from("Linia życia"),
artist: vec![String::from("Frontside")], artist: vec![String::from("Frontside")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 987,
},
}, },
], ],
}], }],
@ -327,43 +456,64 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
number: 01, number: 01,
title: String::from("Unbreakable"), title: String::from("Unbreakable"),
artist: vec![String::from("Heavens Basement")], artist: vec![String::from("Heavens Basement")],
quality: Quality::Mp3(208), quality: Quality {
format: Format::Mp3,
bitrate: 208,
},
}, },
Track { Track {
number: 02, number: 02,
title: String::from("Guilt Trips and Sins"), title: String::from("Guilt Trips and Sins"),
artist: vec![String::from("Heavens Basement")], artist: vec![String::from("Heavens Basement")],
quality: Quality::Mp3(205), quality: Quality {
format: Format::Mp3,
bitrate: 205,
},
}, },
Track { Track {
number: 03, number: 03,
title: String::from("The Long Goodbye"), title: String::from("The Long Goodbye"),
artist: vec![String::from("Heavens Basement")], artist: vec![String::from("Heavens Basement")],
quality: Quality::Mp3(227), quality: Quality {
format: Format::Mp3,
bitrate: 227,
},
}, },
Track { Track {
number: 04, number: 04,
title: String::from("Close Encounters"), title: String::from("Close Encounters"),
artist: vec![String::from("Heavens Basement")], artist: vec![String::from("Heavens Basement")],
quality: Quality::Mp3(213), quality: Quality {
format: Format::Mp3,
bitrate: 213,
},
}, },
Track { Track {
number: 05, number: 05,
title: String::from("Paranoia"), title: String::from("Paranoia"),
artist: vec![String::from("Heavens Basement")], artist: vec![String::from("Heavens Basement")],
quality: Quality::Mp3(218), quality: Quality {
format: Format::Mp3,
bitrate: 218,
},
}, },
Track { Track {
number: 06, number: 06,
title: String::from("Let Me Out of Here"), title: String::from("Let Me Out of Here"),
artist: vec![String::from("Heavens Basement")], artist: vec![String::from("Heavens Basement")],
quality: Quality::Mp3(207), quality: Quality {
format: Format::Mp3,
bitrate: 207,
},
}, },
Track { Track {
number: 07, number: 07,
title: String::from("Leeches"), title: String::from("Leeches"),
artist: vec![String::from("Heavens Basement")], artist: vec![String::from("Heavens Basement")],
quality: Quality::Mp3(225), quality: Quality {
format: Format::Mp3,
bitrate: 225,
},
}, },
], ],
}], }],
@ -383,49 +533,73 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
number: 01, number: 01,
title: String::from("Fight Fire with Fire"), title: String::from("Fight Fire with Fire"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 954,
},
}, },
Track { Track {
number: 02, number: 02,
title: String::from("Ride the Lightning"), title: String::from("Ride the Lightning"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 951,
},
}, },
Track { Track {
number: 03, number: 03,
title: String::from("For Whom the Bell Tolls"), title: String::from("For Whom the Bell Tolls"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 889,
},
}, },
Track { Track {
number: 04, number: 04,
title: String::from("Fade to Black"), title: String::from("Fade to Black"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 939,
},
}, },
Track { Track {
number: 05, number: 05,
title: String::from("Trapped under Ice"), title: String::from("Trapped under Ice"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 955,
},
}, },
Track { Track {
number: 06, number: 06,
title: String::from("Escape"), title: String::from("Escape"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 941,
},
}, },
Track { Track {
number: 07, number: 07,
title: String::from("Creeping Death"), title: String::from("Creeping Death"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 958,
},
}, },
Track { Track {
number: 08, number: 08,
title: String::from("The Call of Ktulu"), title: String::from("The Call of Ktulu"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 888,
},
}, },
], ],
}, },
@ -439,127 +613,190 @@ static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| {
number: 01, number: 01,
title: String::from("The Ecstasy of Gold"), title: String::from("The Ecstasy of Gold"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 875,
},
}, },
Track { Track {
number: 02, number: 02,
title: String::from("The Call of Ktulu"), title: String::from("The Call of Ktulu"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1030,
},
}, },
Track { Track {
number: 03, number: 03,
title: String::from("Master of Puppets"), title: String::from("Master of Puppets"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1082,
},
}, },
Track { Track {
number: 04, number: 04,
title: String::from("Of Wolf and Man"), title: String::from("Of Wolf and Man"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1115,
},
}, },
Track { Track {
number: 05, number: 05,
title: String::from("The Thing That Should Not Be"), title: String::from("The Thing That Should Not Be"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1029,
},
}, },
Track { Track {
number: 06, number: 06,
title: String::from("Fuel"), title: String::from("Fuel"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1057,
},
}, },
Track { Track {
number: 07, number: 07,
title: String::from("The Memory Remains"), title: String::from("The Memory Remains"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1080,
},
}, },
Track { Track {
number: 08, number: 08,
title: String::from("No Leaf Clover"), title: String::from("No Leaf Clover"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1004,
},
}, },
Track { Track {
number: 09, number: 09,
title: String::from("Hero of the Day"), title: String::from("Hero of the Day"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 962,
},
}, },
Track { Track {
number: 10, number: 10,
title: String::from("Devils Dance"), title: String::from("Devils Dance"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1076,
},
}, },
Track { Track {
number: 11, number: 11,
title: String::from("Bleeding Me"), title: String::from("Bleeding Me"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 993,
},
}, },
Track { Track {
number: 12, number: 12,
title: String::from("Nothing Else Matters"), title: String::from("Nothing Else Matters"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 875,
},
}, },
Track { Track {
number: 13, number: 13,
title: String::from("Until It Sleeps"), title: String::from("Until It Sleeps"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1038,
},
}, },
Track { Track {
number: 14, number: 14,
title: String::from("For Whom the Bell Tolls"), title: String::from("For Whom the Bell Tolls"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1072,
},
}, },
Track { Track {
number: 15, number: 15,
title: String::from("Human"), title: String::from("Human"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1029,
},
}, },
Track { Track {
number: 16, number: 16,
title: String::from("Wherever I May Roam"), title: String::from("Wherever I May Roam"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1035,
},
}, },
Track { Track {
number: 17, number: 17,
title: String::from("Outlaw Torn"), title: String::from("Outlaw Torn"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1042,
},
}, },
Track { Track {
number: 18, number: 18,
title: String::from("Sad but True"), title: String::from("Sad but True"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1082,
},
}, },
Track { Track {
number: 19, number: 19,
title: String::from("One"), title: String::from("One"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 1017,
},
}, },
Track { Track {
number: 20, number: 20,
title: String::from("Enter Sandman"), title: String::from("Enter Sandman"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 993,
},
}, },
Track { Track {
number: 21, number: 21,
title: String::from("Battery"), title: String::from("Battery"),
artist: vec![String::from("Metallica")], artist: vec![String::from("Metallica")],
quality: Quality::Flac, quality: Quality {
format: Format::Flac,
bitrate: 967,
},
}, },
], ],
}, },