use std::borrow::Cow;
use tweet::StatusId;
use user::UserId;
pub type MediaId = u64;
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash)]
pub struct Entities<'a> {
#[serde(borrow)]
pub hashtags: Vec<Hashtag<'a>>,
#[serde(borrow)]
pub media: Option<Vec<Media<'a>>>,
#[serde(borrow)]
pub urls: Vec<Url<'a>>,
#[serde(borrow)]
pub user_mentions: Vec<UserMention<'a>>,
#[serde(borrow)]
pub symbols: Vec<Symbol<'a>>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash)]
pub struct Hashtag<'a> {
pub indices: (u64, u64),
#[serde(borrow)]
pub text: Cow<'a, str>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash)]
pub struct Media<'a> {
#[serde(borrow)]
pub display_url: Cow<'a, str>,
#[serde(borrow)]
pub expanded_url: Cow<'a, str>,
pub id: MediaId,
pub indices: (u64, u64),
#[serde(borrow)]
pub media_url: Cow<'a, str>,
#[serde(borrow)]
pub media_url_https: Cow<'a, str>,
#[serde(borrow)]
pub sizes: Sizes<'a>,
pub source_status_id: Option<StatusId>,
#[serde(borrow)]
#[serde(rename="type")]
pub kind: Cow<'a, str>,
#[serde(borrow)]
pub url: Cow<'a, str>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash)]
pub struct Sizes<'a> {
#[serde(borrow)]
pub thumb: Size<'a>,
#[serde(borrow)]
pub large: Size<'a>,
#[serde(borrow)]
pub medium: Size<'a>,
#[serde(borrow)]
pub small: Size<'a>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash)]
pub struct Size<'a> {
pub h: u64,
#[serde(borrow)]
pub resize: Resize<'a>,
pub w: u64,
}
string_enums! {
#[derive(Clone, Debug)]
pub enum Resize<'a> {
Fit("fit"),
Crop("crop");
Custom(_),
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash)]
pub struct Url<'a> {
#[serde(borrow)]
#[serde(default)]
#[serde(deserialize_with = "::util::deserialize_default")]
pub display_url: Cow<'a, str>,
#[serde(borrow)]
#[serde(default)]
#[serde(deserialize_with = "::util::deserialize_default")]
pub expanded_url: Cow<'a, str>,
pub indices: (u64, u64),
#[serde(borrow)]
pub url: Cow<'a, str>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash)]
pub struct UserMention<'a> {
pub id: UserId,
pub indices: (u64, u64),
#[serde(borrow)]
pub name: Cow<'a, str>,
#[serde(borrow)]
pub screen_name: Cow<'a, str>,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Hash)]
pub struct Symbol<'a> {
#[serde(borrow)]
pub text: Cow<'a, str>,
pub indices: (u64, u64),
}