const IMAGE_BASE_URL: &str = "https://image.tmdb.org/t/p/";
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum PosterSize {
W92,
W154,
W185,
W342,
W500,
W780,
Original,
}
impl PosterSize {
fn as_str(&self) -> &'static str {
match self {
PosterSize::W92 => "w92",
PosterSize::W154 => "w154",
PosterSize::W185 => "w185",
PosterSize::W342 => "w342",
PosterSize::W500 => "w500",
PosterSize::W780 => "w780",
PosterSize::Original => "original",
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum BackdropSize {
W300,
W780,
W1280,
Original,
}
impl BackdropSize {
fn as_str(&self) -> &'static str {
match self {
BackdropSize::W300 => "w300",
BackdropSize::W780 => "w780",
BackdropSize::W1280 => "w1280",
BackdropSize::Original => "original",
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ProfileSize {
W45,
W185,
H632,
Original,
}
impl ProfileSize {
fn as_str(&self) -> &'static str {
match self {
ProfileSize::W45 => "w45",
ProfileSize::W185 => "w185",
ProfileSize::H632 => "h632",
ProfileSize::Original => "original",
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum StillSize {
W92,
W185,
W300,
Original,
}
impl StillSize {
fn as_str(&self) -> &'static str {
match self {
StillSize::W92 => "w92",
StillSize::W185 => "w185",
StillSize::W300 => "w300",
StillSize::Original => "original",
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum LogoSize {
W45,
W92,
W154,
W185,
W300,
W500,
Original,
}
impl LogoSize {
fn as_str(&self) -> &'static str {
match self {
LogoSize::W45 => "w45",
LogoSize::W92 => "w92",
LogoSize::W154 => "w154",
LogoSize::W185 => "w185",
LogoSize::W300 => "w300",
LogoSize::W500 => "w500",
LogoSize::Original => "original",
}
}
}
pub struct ImageUrl;
impl ImageUrl {
pub fn poster(path: &str, size: PosterSize) -> String {
format!("{IMAGE_BASE_URL}{}{path}", size.as_str())
}
pub fn backdrop(path: &str, size: BackdropSize) -> String {
format!("{IMAGE_BASE_URL}{}{path}", size.as_str())
}
pub fn profile(path: &str, size: ProfileSize) -> String {
format!("{IMAGE_BASE_URL}{}{path}", size.as_str())
}
pub fn still(path: &str, size: StillSize) -> String {
format!("{IMAGE_BASE_URL}{}{path}", size.as_str())
}
pub fn logo(path: &str, size: LogoSize) -> String {
format!("{IMAGE_BASE_URL}{}{path}", size.as_str())
}
}