Skip to main content

wax/
model.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4#[serde(rename_all = "lowercase")]
5pub enum Platform {
6    Bandcamp,
7    Soundcloud,
8}
9
10impl Platform {
11    pub fn as_str(self) -> &'static str {
12        match self {
13            Self::Bandcamp => "bandcamp",
14            Self::Soundcloud => "soundcloud",
15        }
16    }
17}
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
20#[serde(rename_all = "lowercase")]
21pub enum ItemKind {
22    Album,
23    Track,
24    Playlist,
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct SeedAlbum {
29    pub platform: Platform,
30    pub kind: ItemKind,
31    pub title: String,
32    pub artist: String,
33    pub url: String,
34    pub artist_url: Option<String>,
35    pub tags: Vec<String>,
36    pub label: Option<String>,
37    pub release_id: Option<String>,
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct Collector {
42    pub handle: String,
43    pub url: String,
44    pub display_name: Option<String>,
45    pub visible: bool,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct OwnedAlbum {
50    pub platform: Platform,
51    pub kind: ItemKind,
52    pub title: String,
53    pub artist: String,
54    pub url: String,
55    pub tags: Vec<String>,
56    pub label: Option<String>,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct CandidateRecord {
61    pub rank: usize,
62    pub title: String,
63    pub artist: String,
64    pub url: String,
65    pub overlap_count: usize,
66    pub overlap_ratio: f64,
67    pub score: f64,
68    pub reason: String,
69    pub collectors: Vec<String>,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
73pub struct CrawlSummary {
74    pub collectors_discovered: usize,
75    pub collectors_sampled: usize,
76    pub collectors_scanned: usize,
77    pub collectors_skipped: usize,
78    pub candidates_ranked: usize,
79    pub cache_hits: usize,
80    pub cache_misses: usize,
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize)]
84pub struct ResolveOutput {
85    pub seed: SeedAlbum,
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
89pub struct CollectorsOutput {
90    pub seed: SeedAlbum,
91    pub collectors_discovered: usize,
92    pub collectors: Vec<Collector>,
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
96pub struct LibraryOutput {
97    pub collector_url: String,
98    pub albums: Vec<OwnedAlbum>,
99}
100
101#[derive(Debug, Clone, Serialize, Deserialize)]
102pub struct DigOutput {
103    pub seed: SeedAlbum,
104    pub summary: CrawlSummary,
105    pub results: Vec<CandidateRecord>,
106}