use core::fmt; use core::marker::PhantomData; /// The TMDB ID type of a movie genre pub type MovieGenreId = TmdbId; /// The TMDB ID type of a show genre pub type ShowGenreId = TmdbId; /// The TMDB ID type of a collection pub type CollectionId = TmdbId; /// The TMDB ID type of a movie pub type MovieId = TmdbId; /// The TMDB ID type of a show pub type ShowId = TmdbId; pub enum MovieGenre {} pub enum ShowGenre {} pub enum Collection {} pub enum Movie {} pub enum Show {} /// The inner type of TmdbId pub type Inner = i32; /// Wraps an ID from TMDB, the generic parameter is to enforce that /// IDs for different types of media are not interchangeable #[derive(serde::Serialize, serde::Deserialize)] #[serde(transparent)] #[repr(transparent)] pub struct TmdbId { inner: Inner, #[serde(skip_serializing, default)] _phantom: PhantomData, } impl TmdbId { /// Extract the inner value pub fn inner(self) -> Inner { self.inner } } impl From for TmdbId { fn from(value: Inner) -> Self { Self { inner: value, _phantom: PhantomData, } } } impl From> for Inner { fn from(value: TmdbId) -> Self { value.inner } } impl fmt::Debug for TmdbId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } } impl fmt::Display for TmdbId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } } impl Clone for TmdbId { fn clone(&self) -> Self { *self } } impl Copy for TmdbId {} impl PartialEq for TmdbId { fn eq(&self, other: &Self) -> bool { self.inner == other.inner } } impl Eq for TmdbId {}