First draft of public data structures #2
20
src/lib.rs
20
src/lib.rs
@ -1,35 +1,37 @@
|
||||
//! MusicHoard - a music collection manager.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid;
|
||||
|
||||
/// The [MusicBrainz Identifier](https://musicbrainz.org/doc/MusicBrainz_Identifier).
|
||||
type Mbid = uuid::Uuid;
|
||||
/// [MusicBrainz Identifier](https://musicbrainz.org/doc/MusicBrainz_Identifier) (MBID).
|
||||
pub type Mbid = uuid::Uuid;
|
||||
|
||||
/// An artist. May be linked to MusicBrainz.
|
||||
/// [Artist](https://musicbrainz.org/doc/Artist).
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Artist {
|
||||
pub name: String,
|
||||
pub mbid: Option<Mbid>,
|
||||
}
|
||||
|
||||
/// A single track on a release.
|
||||
/// [Track](https://musicbrainz.org/doc/Track).
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Track {
|
||||
pub number: u32,
|
||||
pub title: String,
|
||||
pub artist: Artist,
|
||||
pub mbid: Option<Mbid>,
|
||||
}
|
||||
|
||||
/// MusicHoard release corresponds to MusicBrainz' concept of a release. However, it does not link
|
||||
/// to MusicBrainz as the intention of MusicHoard is to manage releases locally.
|
||||
/// [Release](https://musicbrainz.org/doc/Release).
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Release {
|
||||
pub title: String,
|
||||
pub artist: String,
|
||||
pub tracks: Vec<Track>,
|
||||
pub mbid: Option<Mbid>,
|
||||
}
|
||||
|
||||
/// MusicHoard uses MusicBrainz [primary release group
|
||||
/// type](https://musicbrainz.org/doc/Release_Group/Type)
|
||||
/// [Release group primary type](https://musicbrainz.org/doc/Release_Group/Type).
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum ReleaseGroupType {
|
||||
Album,
|
||||
@ -38,7 +40,7 @@ pub enum ReleaseGroupType {
|
||||
Other,
|
||||
}
|
||||
|
||||
/// MusicHoard uses MusicBrainz' [Release Group concept](https://musicbrainz.org/doc/Release_Group).
|
||||
/// [Release group](https://musicbrainz.org/doc/Release_Group).
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct ReleaseGroup {
|
||||
pub r#type: ReleaseGroupType,
|
||||
|
Loading…
Reference in New Issue
Block a user