musichoard/src/lib.rs

68 lines
1.4 KiB
Rust
Raw Normal View History

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