#[macro_use]
extern crate serde;
extern crate serde_json;
pub mod client;
#[derive(Debug)]
pub enum Error {
HttpUrlEncode(Box<dyn std::error::Error>),
HttpGet(Box<dyn std::error::Error>),
ParseError(serde_json::Error),
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
type Result<T> = std::result::Result<T, Error>;
#[derive(Deserialize, Serialize, Clone, PartialEq, PartialOrd, Hash, Debug, Default)]
pub struct Provider {
#[serde(rename = "provider_name")]
pub name: String,
#[serde(rename = "provider_url")]
pub url: String,
pub endpoints: Vec<Endpoint>,
}
#[derive(Deserialize, Serialize, Clone, PartialEq, PartialOrd, Hash, Debug, Default)]
pub struct Endpoint {
pub url: String,
pub schemes: Option<Vec<String>>,
pub formats: Option<Vec<String>>,
pub discovery: Option<bool>,
}
#[derive(Deserialize, Serialize, Clone, PartialEq, PartialOrd, Hash, Debug)]
pub struct Response {
#[serde(flatten, rename(deserialize = "type"))]
pub response_type: ResponseType,
pub version: String,
pub title: Option<String>,
pub author_name: Option<String>,
pub author_url: Option<String>,
pub provider_name: Option<String>,
pub provider_url: Option<String>,
pub cache_age: Option<String>,
pub thumbnail_url: Option<String>,
pub thumbnail_width: Option<i32>,
pub thumbnail_height: Option<i32>,
}
#[derive(Deserialize, Serialize, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
#[serde(tag = "type", rename_all(deserialize = "lowercase"))]
pub enum ResponseType {
Photo {
url: String,
width: Option<i32>,
height: Option<i32>,
},
Video {
html: String,
width: Option<i32>,
height: Option<i32>,
},
Rich {
html: String,
width: Option<i32>,
height: Option<i32>,
},
Link,
}