2023-03-29 01:29:11 +02:00
|
|
|
//! MusicHoard - a music collection manager.
|
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
2023-03-29 08:37:01 +02:00
|
|
|
use uuid::Uuid;
|
|
|
|
|
2023-04-13 14:09:59 +02:00
|
|
|
pub mod collection;
|
2023-03-29 08:37:01 +02:00
|
|
|
pub mod database;
|
2023-03-31 14:24:54 +02:00
|
|
|
pub mod library;
|
2023-03-29 01:29:11 +02:00
|
|
|
|
|
|
|
/// [MusicBrainz Identifier](https://musicbrainz.org/doc/MusicBrainz_Identifier) (MBID).
|
2023-03-29 08:37:01 +02:00
|
|
|
pub type Mbid = Uuid;
|
2023-03-29 01:29:11 +02:00
|
|
|
|
2023-04-10 11:27:07 +02:00
|
|
|
/// The track file format.
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
|
|
|
pub enum TrackFormat {
|
|
|
|
Flac,
|
|
|
|
Mp3,
|
|
|
|
}
|
|
|
|
|
2023-03-31 14:24:54 +02:00
|
|
|
/// A single track on an album.
|
2023-04-10 00:13:18 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
2023-03-29 01:29:11 +02:00
|
|
|
pub struct Track {
|
|
|
|
pub number: u32,
|
|
|
|
pub title: String,
|
2023-03-31 14:24:54 +02:00
|
|
|
pub artist: Vec<String>,
|
2023-04-10 11:27:07 +02:00
|
|
|
pub format: TrackFormat,
|
2023-03-28 22:49:59 +02:00
|
|
|
}
|
|
|
|
|
2023-03-31 14:24:54 +02:00
|
|
|
/// The album identifier.
|
2023-04-10 00:13:18 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
|
2023-03-31 14:24:54 +02:00
|
|
|
pub struct AlbumId {
|
|
|
|
pub year: u32,
|
|
|
|
pub title: String,
|
2023-03-29 01:29:11 +02:00
|
|
|
}
|
2023-03-28 22:49:59 +02:00
|
|
|
|
2023-03-31 14:24:54 +02:00
|
|
|
/// An album is a collection of tracks that were released together.
|
2023-04-10 00:13:18 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
2023-03-31 14:24:54 +02:00
|
|
|
pub struct Album {
|
|
|
|
pub id: AlbumId,
|
|
|
|
pub tracks: Vec<Track>,
|
2023-03-28 22:49:59 +02:00
|
|
|
}
|
2023-04-01 01:59:59 +02:00
|
|
|
|
|
|
|
/// The artist identifier.
|
2023-04-10 00:13:18 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
|
2023-04-01 01:59:59 +02:00
|
|
|
pub struct ArtistId {
|
|
|
|
pub name: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// An artist.
|
2023-04-10 00:13:18 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
2023-04-01 01:59:59 +02:00
|
|
|
pub struct Artist {
|
|
|
|
pub id: ArtistId,
|
|
|
|
pub albums: Vec<Album>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
2023-04-13 14:09:59 +02:00
|
|
|
#[macro_use]
|
|
|
|
mod testlib;
|
2023-04-01 01:59:59 +02:00
|
|
|
|
2023-04-13 14:09:59 +02:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2023-04-10 00:13:18 +02:00
|
|
|
use once_cell::sync::Lazy;
|
|
|
|
|
2023-04-13 14:09:59 +02:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| collection!());
|
2023-04-01 01:59:59 +02:00
|
|
|
}
|