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
105
use crate::model::*;
macro_rules! inherit_track_simplified {
($(#[$attr:meta])* $name:ident { $($(#[$f_attr:meta])* $f_name:ident : $f_ty:ty,)* }) => {
to_struct!($(#[$attr])* $name {
$(
$(#[$f_attr])*
$f_name: $f_ty,
)*
/// The artists who performed the track.
artists: Vec<ArtistSimplified>,
/// The markets in which this track is available. Only Some if the market parameter is
/// not supplied in the request.
available_markets: Option<Vec<CountryCode>>,
/// The disc number (1 unless the album contains more than one disc).
disc_number: usize,
/// The track length.
#[serde(rename = "duration_ms", with = "serde_millis")]
duration: Duration,
/// Whether the track has explicit lyrics, false if unknown.
explicit: bool,
/// Known external URLs for this track.
external_urls: HashMap<String, String>,
/// The [Spotify ID](https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids)
/// for this track.
id: String,
/// When [track
/// relinking](https://developer.spotify.com/documentation/general/guides/track-relinking-guide/)
/// is applied, if the track is playable in the given market.
is_playable: Option<bool>,
/// When [track
/// relinking](https://developer.spotify.com/documentation/general/guides/track-relinking-guide/)
/// is applied and the requested track has been replaced by a different one.
linked_from: Option<TrackLink>,
/// When [track
/// relinking](https://developer.spotify.com/documentation/general/guides/track-relinking-guide/)
/// is applied, the original track isn't available in the given market and Spotify didn't have
/// any tracks to relink it with, then this is Some.
restrictions: Option<Restrictions>,
/// The name of the track.
name: String,
/// Link to a 30 second MP3 preview of the track, doesn't have to be there.
preview_url: Option<String>,
/// The 1-indexed number of the track in its album; if the track has several discs,
/// then it the number on the specified disc.
track_number: usize,
/// Whether the track is from a local file.
is_local: bool,
});
}
}
inherit_track_simplified!(
/// A simplified track object.
TrackSimplified {}
);
inherit_track_simplified!(
/// A track object.
Track {
/// The album on which this track appears.
album: AlbumSimplified,
/// Known external IDs for this track.
external_ids: HashMap<String, String>,
/// The popularity of the track. The value will be between 0 and 100, with 100 being the most
/// popular. The popularity is calculated from the total number of plays and how recent they
/// are.
popularity: u32,
}
);
/// A link to a track.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct TrackLink {
/// Known external URLs for this track.
pub external_urls: HashMap<String, String>,
/// The [Spotify ID](https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids)
/// for this track.
pub id: String,
}
/// When and how a track was played.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PlayHistory {
/// The track the user listened to.
pub track: TrackSimplified,
/// When the track was played.
pub played_at: DateTime<Utc>,
/// The context from which the track was played.
pub context: Option<Context>,
}
/// Information about a track that has been saved.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SavedTrack {
/// When the track was saved.
pub added_at: DateTime<Utc>,
/// Information about the track.
pub track: Track,
}
/// The number of tracks an object contains.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Tracks {
pub total: usize,
}