rspotify_model/enums/
types.rs

1use serde::{Deserialize, Serialize};
2use strum::{Display, EnumString, IntoStaticStr};
3
4/// Copyright type: `C` = the copyright, `P` = the sound recording (performance)
5/// copyright.
6#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, IntoStaticStr)]
7pub enum CopyrightType {
8    #[strum(serialize = "P")]
9    #[serde(rename = "P")]
10    Performance,
11    #[strum(serialize = "C")]
12    #[serde(rename = "C")]
13    Copyright,
14}
15
16/// Album type: `album`, `single`, `appears_on`, `compilation`
17#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, IntoStaticStr)]
18#[serde(rename_all = "snake_case")]
19#[strum(serialize_all = "snake_case")]
20pub enum AlbumType {
21    Album,
22    Single,
23    AppearsOn,
24    Compilation,
25}
26
27/// Type: `artist`, `album`, `track`, `playlist`, `show` or `episode`
28#[derive(
29    Clone, Serialize, Deserialize, PartialEq, Eq, Debug, Display, EnumString, IntoStaticStr,
30)]
31#[serde(rename_all = "snake_case")]
32#[strum(serialize_all = "snake_case")]
33pub enum Type {
34    Artist,
35    Album,
36    Track,
37    Playlist,
38    User,
39    Show,
40    Episode,
41    Collection,
42    Collectionyourepisodes, // rename to collectionyourepisodes
43    // Fallback variant to capture unknown variants introduced by
44    // Spotify rather than raise a deserialization error.
45    #[serde(untagged)]
46    Unknown(String),
47}
48
49/// Additional typs: `track`, `episode`
50#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, IntoStaticStr)]
51#[serde(rename_all = "snake_case")]
52#[strum(serialize_all = "snake_case")]
53pub enum AdditionalType {
54    Track,
55    Episode,
56}
57
58/// Currently playing type: `track`, `episode`, `ad`, `unknown`
59#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, IntoStaticStr)]
60#[serde(rename_all = "snake_case")]
61#[strum(serialize_all = "snake_case")]
62pub enum CurrentlyPlayingType {
63    Track,
64    Episode,
65    #[strum(serialize = "ad")]
66    #[serde(rename = "ad")]
67    Advertisement,
68    Unknown,
69}
70
71/// Type for search: `artist`, `album`, `track`, `playlist`, `show`, `episode`
72#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, IntoStaticStr)]
73#[serde(rename_all = "snake_case")]
74#[strum(serialize_all = "snake_case")]
75pub enum SearchType {
76    Artist,
77    Album,
78    Track,
79    Playlist,
80    Show,
81    Episode,
82}
83
84/// The user's Spotify subscription level: `premium`, `free`
85///
86/// (The subscription level "open" can be considered the same as "free".)
87#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, IntoStaticStr)]
88#[serde(rename_all = "snake_case")]
89#[strum(serialize_all = "snake_case")]
90pub enum SubscriptionLevel {
91    Premium,
92    #[serde(alias = "open")]
93    Free,
94}
95
96/// Device Type: `computer`, `smartphone`, `speaker`, `TV`
97#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, IntoStaticStr)]
98#[strum(serialize_all = "snake_case")]
99pub enum DeviceType {
100    Computer,
101    Tablet,
102    Smartphone,
103    Smartwatch,
104    Speaker,
105    /// Though undocumented, it has been reported that the Web API returns both
106    /// 'Tv' and 'TV' as the type.
107    #[serde(alias = "TV")]
108    Tv,
109    /// Same as above, the Web API returns both 'AVR' and 'Avr' as the type.
110    #[serde(alias = "AVR")]
111    Avr,
112    /// Same as above, the Web API returns both 'STB' and 'Stb' as the type.
113    #[serde(alias = "STB")]
114    Stb,
115    AudioDongle,
116    GameConsole,
117    CastVideo,
118    CastAudio,
119    Automobile,
120    Unknown,
121}
122
123/// Recommendations seed type
124#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, IntoStaticStr)]
125#[serde(rename_all = "UPPERCASE")]
126pub enum RecommendationsSeedType {
127    Artist,
128    Track,
129    Genre,
130}