musichoard/src/lib.rs

53 lines
1.2 KiB
Rust
Raw Normal View History

2023-03-29 02:44:59 +02:00
//! MusicHoard - a music collection manager.
2023-03-29 01:29:11 +02:00
use serde::{Deserialize, Serialize};
use uuid;
2023-03-29 02:44:59 +02:00
/// [MusicBrainz Identifier](https://musicbrainz.org/doc/MusicBrainz_Identifier) (MBID).
pub type Mbid = uuid::Uuid;
2023-03-29 01:29:11 +02:00
2023-03-29 02:44:59 +02:00
/// [Artist](https://musicbrainz.org/doc/Artist).
2023-03-29 01:29:11 +02:00
#[derive(Deserialize, Serialize)]
pub struct Artist {
pub name: String,
pub mbid: Option<Mbid>,
}
2023-03-29 02:44:59 +02:00
/// [Track](https://musicbrainz.org/doc/Track).
2023-03-29 01:29:11 +02:00
#[derive(Deserialize, Serialize)]
pub struct Track {
pub number: u32,
pub title: String,
pub artist: Artist,
2023-03-29 02:44:59 +02:00
pub mbid: Option<Mbid>,
2023-03-28 22:49:59 +02:00
}
2023-03-29 02:44:59 +02:00
/// [Release](https://musicbrainz.org/doc/Release).
2023-03-29 01:29:11 +02:00
#[derive(Deserialize, Serialize)]
pub struct Release {
pub title: String,
pub artist: String,
pub tracks: Vec<Track>,
2023-03-29 02:44:59 +02:00
pub mbid: Option<Mbid>,
2023-03-29 01:29:11 +02:00
}
2023-03-29 02:44:59 +02:00
/// [Release group primary type](https://musicbrainz.org/doc/Release_Group/Type).
2023-03-29 01:29:11 +02:00
#[derive(Deserialize, Serialize)]
pub enum ReleaseGroupType {
Album,
Ep,
Single,
Other,
}
2023-03-28 22:49:59 +02:00
2023-03-29 02:44:59 +02:00
/// [Release group](https://musicbrainz.org/doc/Release_Group).
2023-03-29 01:29:11 +02:00
#[derive(Deserialize, Serialize)]
pub struct ReleaseGroup {
pub r#type: ReleaseGroupType,
pub title: String,
pub artist: Artist,
pub year: u32,
pub mbid: Option<Mbid>,
pub releases: Vec<Release>,
2023-03-28 22:49:59 +02:00
}