1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use chrono::prelude::*;
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, time::Duration};
use crate::{
custom_serde::duration_ms, PlayableId, Restriction, SimplifiedAlbum, SimplifiedArtist, TrackId,
};
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct FullTrack {
pub album: SimplifiedAlbum,
pub artists: Vec<SimplifiedArtist>,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub available_markets: Vec<String>,
pub disc_number: i32,
#[serde(with = "duration_ms", rename = "duration_ms")]
pub duration: Duration,
pub explicit: bool,
pub external_ids: HashMap<String, String>,
pub external_urls: HashMap<String, String>,
pub href: Option<String>,
pub id: TrackId,
pub is_local: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_playable: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub linked_from: Option<TrackLink>,
#[serde(skip_serializing_if = "Option::is_none")]
pub restrictions: Option<Restriction>,
pub name: String,
pub popularity: u32,
pub preview_url: Option<String>,
pub track_number: u32,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct TrackLink {
pub external_urls: HashMap<String, String>,
pub href: String,
pub id: TrackId,
}
#[derive(Deserialize)]
pub struct FullTracks {
pub tracks: Vec<FullTrack>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
pub struct SimplifiedTrack {
pub artists: Vec<SimplifiedArtist>,
pub available_markets: Option<Vec<String>>,
pub disc_number: i32,
#[serde(with = "duration_ms", rename = "duration_ms")]
pub duration: Duration,
pub explicit: bool,
pub external_urls: HashMap<String, String>,
#[serde(default)]
pub href: Option<String>,
pub id: Option<TrackId>,
pub is_local: bool,
pub is_playable: Option<bool>,
pub linked_from: Option<TrackLink>,
pub restrictions: Option<Restriction>,
pub name: String,
pub preview_url: Option<String>,
pub track_number: u32,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct SavedTrack {
pub added_at: DateTime<Utc>,
pub track: FullTrack,
}
pub struct ItemPositions<'a> {
pub id: &'a dyn PlayableId,
pub positions: &'a [u32],
}