artifacts: move some of the artifacts code into its own module
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub enum Artifact {
|
||||
Bandcamp(BandcampResult),
|
||||
BeetsTrack(serde_json::Value)
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub enum BandcampResult {
|
||||
Artist { name: String, bio: Option<String>, location: Option<String> },
|
||||
Album { title: String, about: Option<String>, credits: Option<String>, release_date: DateTime<Utc>, artist: String }
|
||||
}
|
||||
|
||||
impl Into<BandcampResult> for bandcamp::Artist {
|
||||
fn into(self) -> BandcampResult {
|
||||
BandcampResult::Artist { name: self.name, bio: self.bio, location: self.location }
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<BandcampResult> for bandcamp::Album {
|
||||
fn into(self) -> BandcampResult {
|
||||
BandcampResult::Album {
|
||||
about: self.about,
|
||||
title: self.title,
|
||||
artist: self.band.name,
|
||||
credits: self.credits,
|
||||
release_date: self.release_date
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Artifact> for bandcamp::Album {
|
||||
fn into(self) -> Artifact {
|
||||
Artifact::Bandcamp(self.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Artifact> for bandcamp::Artist {
|
||||
fn into(self) -> Artifact {
|
||||
Artifact::Bandcamp(self.into())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user