Store date information when writing to database #244
@ -13,6 +13,21 @@ pub enum AlbumLibIdDef {
|
|||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct SerdeAlbumLibId(#[serde(with = "AlbumLibIdDef")] AlbumLibId);
|
||||||
|
|
||||||
|
impl From<SerdeAlbumLibId> for AlbumLibId {
|
||||||
|
fn from(value: SerdeAlbumLibId) -> Self {
|
||||||
|
value.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<AlbumLibId> for SerdeAlbumLibId {
|
||||||
|
fn from(value: AlbumLibId) -> Self {
|
||||||
|
SerdeAlbumLibId(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[serde(remote = "MbRefOption")]
|
#[serde(remote = "MbRefOption")]
|
||||||
pub enum MbRefOptionDef<T> {
|
pub enum MbRefOptionDef<T> {
|
||||||
|
@ -4,7 +4,7 @@ use serde::{de::Visitor, Deserialize, Deserializer};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
collection::{
|
collection::{
|
||||||
album::{AlbumInfo, AlbumLibId, AlbumMeta},
|
album::{AlbumInfo, AlbumMeta},
|
||||||
artist::{ArtistInfo, ArtistMeta},
|
artist::{ArtistInfo, ArtistMeta},
|
||||||
musicbrainz::{MbAlbumRef, MbArtistRef, MbRefOption, Mbid},
|
musicbrainz::{MbAlbumRef, MbArtistRef, MbRefOption, Mbid},
|
||||||
},
|
},
|
||||||
@ -14,7 +14,7 @@ use crate::{
|
|||||||
Collection, Error as CollectionError,
|
Collection, Error as CollectionError,
|
||||||
},
|
},
|
||||||
external::database::serde::common::{
|
external::database::serde::common::{
|
||||||
AlbumLibIdDef, MbRefOptionDef, SerdeAlbumPrimaryType, SerdeAlbumSecondaryType,
|
MbRefOptionDef, SerdeAlbumLibId, SerdeAlbumPrimaryType, SerdeAlbumSecondaryType,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -45,22 +45,13 @@ pub struct DeserializeArtist {
|
|||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct DeserializeAlbum {
|
pub struct DeserializeAlbum {
|
||||||
title: String,
|
title: String,
|
||||||
lib_id: DeserializeAlbumLibId,
|
lib_id: SerdeAlbumLibId,
|
||||||
seq: u8,
|
seq: u8,
|
||||||
musicbrainz: DeserializeMbRefOption,
|
musicbrainz: DeserializeMbRefOption,
|
||||||
primary_type: Option<SerdeAlbumPrimaryType>,
|
primary_type: Option<SerdeAlbumPrimaryType>,
|
||||||
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct DeserializeAlbumLibId(#[serde(with = "AlbumLibIdDef")] AlbumLibId);
|
|
||||||
|
|
||||||
impl From<DeserializeAlbumLibId> for AlbumLibId {
|
|
||||||
fn from(value: DeserializeAlbumLibId) -> Self {
|
|
||||||
value.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct DeserializeMbRefOption(#[serde(with = "MbRefOptionDef")] MbRefOption<DeserializeMbid>);
|
pub struct DeserializeMbRefOption(#[serde(with = "MbRefOptionDef")] MbRefOption<DeserializeMbid>);
|
||||||
|
|
||||||
|
@ -3,13 +3,10 @@ use std::collections::BTreeMap;
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
collection::{
|
collection::musicbrainz::{MbRefOption, Mbid},
|
||||||
album::AlbumLibId,
|
|
||||||
musicbrainz::{MbRefOption, Mbid},
|
|
||||||
},
|
|
||||||
core::collection::{album::Album, artist::Artist, musicbrainz::IMusicBrainzRef, Collection},
|
core::collection::{album::Album, artist::Artist, musicbrainz::IMusicBrainzRef, Collection},
|
||||||
external::database::serde::common::{
|
external::database::serde::common::{
|
||||||
AlbumLibIdDef, MbRefOptionDef, SerdeAlbumPrimaryType, SerdeAlbumSecondaryType,
|
MbRefOptionDef, SerdeAlbumLibId, SerdeAlbumPrimaryType, SerdeAlbumSecondaryType,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,22 +33,13 @@ pub struct SerializeArtist<'a> {
|
|||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct SerializeAlbum<'a> {
|
pub struct SerializeAlbum<'a> {
|
||||||
title: &'a str,
|
title: &'a str,
|
||||||
lib_id: SerializeAlbumLibId,
|
lib_id: SerdeAlbumLibId,
|
||||||
seq: u8,
|
seq: u8,
|
||||||
musicbrainz: SerializeMbRefOption<'a>,
|
musicbrainz: SerializeMbRefOption<'a>,
|
||||||
primary_type: Option<SerdeAlbumPrimaryType>,
|
primary_type: Option<SerdeAlbumPrimaryType>,
|
||||||
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
|
||||||
pub struct SerializeAlbumLibId(#[serde(with = "AlbumLibIdDef")] AlbumLibId);
|
|
||||||
|
|
||||||
impl From<AlbumLibId> for SerializeAlbumLibId {
|
|
||||||
fn from(value: AlbumLibId) -> Self {
|
|
||||||
SerializeAlbumLibId(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct SerializeMbRefOption<'a>(
|
pub struct SerializeMbRefOption<'a>(
|
||||||
#[serde(with = "MbRefOptionDef")] MbRefOption<SerializeMbid<'a>>,
|
#[serde(with = "MbRefOptionDef")] MbRefOption<SerializeMbid<'a>>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user