pub mod album;
pub mod artist;
pub mod error;
pub mod id;
pub mod playback;
pub mod search;
pub mod track;
pub mod user;
mod country_code;
pub(crate) mod object_type;
mod page;
use std::{fmt, str::FromStr};
pub use country_code::CountryCode;
pub use page::Page;
use serde::{Deserialize, Serialize};
use crate::error::IdError;
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Image {
pub url: String,
#[serde(flatten)]
pub dimensions: Option<ImageDimensions>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ImageDimensions {
pub width: u32,
pub height: u32,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Restrictions {
pub reason: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum DatePrecision {
Year,
Month,
Day,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExternalUrls {
pub spotify: Option<String>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExternalIds {
pub isrc: Option<String>,
pub ean: Option<String>,
pub upc: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Copyright {
pub text: String,
pub copyright_type: CopyrightType,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum CopyrightType {
#[serde(rename = "P")]
Performance,
C, }
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum ItemType {
Album,
Artist,
Playlist,
Track,
Show,
Episode,
Collection,
User,
}
impl crate::private::Sealed for ItemType {}
impl fmt::Display for ItemType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ItemType::Album => write!(f, "album"),
ItemType::Artist => write!(f, "artist"),
ItemType::Playlist => write!(f, "playlist"),
ItemType::Track => write!(f, "track"),
ItemType::Show => write!(f, "show"),
ItemType::Episode => write!(f, "episode"),
ItemType::Collection => write!(f, "collection"),
ItemType::User => write!(f, "user"),
}
}
}
impl FromStr for ItemType {
type Err = crate::error::IdError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"album" => Ok(Self::Album),
"artist" => Ok(Self::Artist),
"playlist" => Ok(Self::Playlist),
"track" => Ok(Self::Track),
"show" => Ok(Self::Show),
"episode" => Ok(Self::Episode),
"collection" => Ok(Self::Collection),
"user" => Ok(Self::User),
other => Err(IdError::InvalidItemType(other.to_owned())),
}
}
}