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