//use std::fmt; use serde::Deserialize; extern crate reqwest; extern crate serde_json; #[derive(Debug, Deserialize)] pub struct Album { pub title: String, pub is_mature: bool, pub media: Vec, } #[derive(Debug, Deserialize)] pub struct Media { pub r#type: String, pub url: String, pub width: u32, pub height: u32, pub metadata: Metadata, } #[derive(Debug, Deserialize)] pub struct Metadata { pub description: String, pub duration: f32, } #[derive(Debug)] pub enum Error { Reqwest(reqwest::Error), SerdeJSON(serde_json::Error), APIErrors(APIErrors), } impl From for Error { #[inline] fn from(error: reqwest::Error) -> Error { Error::Reqwest(error) } } impl From for Error { #[inline] fn from(error: serde_json::Error) -> Error { Error::SerdeJSON(error) } } //impl fmt::Display for Error { // fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { // formatter.write_str(&match self { // Error::Reqwest(err) => format!("reqwest: {}", err), // Error::SerdeJSON(err) => format!("serde_json: {}", err), // Error::ApiErrors(err) => // }) // } //} #[derive(Debug, Deserialize)] pub struct APIErrors { pub errors: Vec, } #[derive(Debug, Deserialize)] pub struct APIError { pub id: String, pub code: String, pub status: String, pub detail: String, }