rspotify_model/enums/
misc.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use strum::IntoStaticStr;
4
5use super::Country;
6
7/// Disallows object: `interrupting_playback`, `pausing`, `resuming`, `seeking`,
8/// `skipping_next`, `skipping_prev`, `toggling_repeat_context`,
9/// `toggling_shuffle`, `toggling_repeat_track`, `transferring_playback`.
10#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, Hash, IntoStaticStr)]
11#[serde(rename_all = "snake_case")]
12#[strum(serialize_all = "snake_case")]
13pub enum DisallowKey {
14    InterruptingPlayback,
15    Pausing,
16    Resuming,
17    Seeking,
18    SkippingNext,
19    SkippingPrev,
20    TogglingRepeatContext,
21    TogglingShuffle,
22    TogglingRepeatTrack,
23    TransferringPlayback,
24}
25
26/// Time range: `long-term`, `medium-term`, `short-term`.
27#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, IntoStaticStr)]
28#[serde(rename_all = "snake_case")]
29#[strum(serialize_all = "snake_case")]
30pub enum TimeRange {
31    LongTerm,
32    MediumTerm,
33    ShortTerm,
34}
35
36/// Repeat state: `track`, `context` or `off`.
37#[derive(Clone, Debug, Copy, Serialize, Deserialize, PartialEq, Eq, IntoStaticStr)]
38#[serde(rename_all = "snake_case")]
39#[strum(serialize_all = "snake_case")]
40pub enum RepeatState {
41    Off,
42    Track,
43    Context,
44}
45
46/// Type for `include_external`: `audio`.
47#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, IntoStaticStr)]
48#[serde(rename_all = "snake_case")]
49#[strum(serialize_all = "snake_case")]
50pub enum IncludeExternal {
51    Audio,
52}
53
54/// Date precision: `year`, `month`, `day`.
55#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, IntoStaticStr)]
56#[serde(rename_all = "snake_case")]
57#[strum(serialize_all = "snake_case")]
58pub enum DatePrecision {
59    Year,
60    Month,
61    Day,
62}
63
64/// The reason for the restriction: `market`, `product`, `explicit`
65#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, IntoStaticStr)]
66#[serde(rename_all = "snake_case")]
67#[strum(serialize_all = "snake_case")]
68pub enum RestrictionReason {
69    Market,
70    Product,
71    Explicit,
72}
73
74/// Indicates the modality (major or minor) of a track.
75///
76/// This field will contain a 0 for `minor`, a 1 for `major` or a -1 for `no
77/// result`
78#[derive(Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Debug, IntoStaticStr)]
79pub enum Modality {
80    Minor = 0,
81    Major = 1,
82    NoResult = -1,
83}
84
85/// Limit the response to a particular market
86///
87/// `FromToken` is the same thing as setting the market parameter to the user's
88/// country.
89#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
90pub enum Market {
91    Country(Country),
92    FromToken,
93}
94
95impl From<Market> for &'static str {
96    fn from(market: Market) -> Self {
97        match market {
98            Market::Country(country) => country.into(),
99            Market::FromToken => "from_token",
100        }
101    }
102}
103
104/// Time limits in miliseconds (unix timestamps)
105#[derive(Clone, Debug, Serialize, Deserialize, Copy, PartialEq, Eq)]
106pub enum TimeLimits {
107    Before(DateTime<Utc>),
108    After(DateTime<Utc>),
109}