//! MusicHoard - a music collection manager. use serde::{Deserialize, Serialize}; use uuid::Uuid; pub mod database; pub mod library; /// [MusicBrainz Identifier](https://musicbrainz.org/doc/MusicBrainz_Identifier) (MBID). pub type Mbid = Uuid; /// A single track on an album. #[derive(Debug, Deserialize, Serialize, PartialEq, Eq)] pub struct Track { pub number: u32, pub title: String, pub artist: Vec, } /// The album identifier. #[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone, Hash)] pub struct AlbumId { pub year: u32, pub title: String, } /// An album is a collection of tracks that were released together. #[derive(Debug, Deserialize, Serialize, PartialEq, Eq)] pub struct Album { pub id: AlbumId, pub tracks: Vec, } /// The artist identifier. #[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone, Hash)] pub struct ArtistId { pub name: String, } /// An artist. #[derive(Debug, Deserialize, Serialize, PartialEq, Eq)] pub struct Artist { pub id: ArtistId, pub albums: Vec, } #[cfg(test)] mod tests { use super::*; pub fn test_data() -> Vec { vec![ Artist { id: ArtistId { name: "album_artist a".to_string(), }, albums: vec![ Album { id: AlbumId { year: 1998, title: "album_title a.a".to_string(), }, tracks: vec![ Track { number: 1, title: "track a.a.1".to_string(), artist: vec!["artist a.a.1".to_string()], }, Track { 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(), ], }, Track { number: 3, title: "track a.a.3".to_string(), artist: vec!["artist a.a.3".to_string()], }, ], }, Album { id: AlbumId { year: 2015, title: "album_title a.b".to_string(), }, tracks: vec![ Track { number: 1, title: "track a.b.1".to_string(), artist: vec!["artist a.b.1".to_string()], }, Track { number: 2, title: "track a.b.2".to_string(), artist: vec!["artist a.b.2".to_string()], }, ], }, ], }, Artist { id: ArtistId { name: "album_artist b.a".to_string(), }, albums: vec![Album { id: AlbumId { year: 2003, title: "album_title b.a".to_string(), }, tracks: vec![ Track { number: 1, title: "track b.a.1".to_string(), artist: vec!["artist b.a.1".to_string()], }, Track { 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(), ], }, ], }], }, ] } }