Initial commit

This commit is contained in:
2025-05-03 15:19:56 -06:00
commit 90c7b9d654
48 changed files with 3192 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
use super::{CollectionId, MovieId};
/// A deserialized Collection from the TMDB API
#[derive(Debug, serde::Deserialize)]
pub struct Collection {
/// The collection's TMDB ID
pub id: CollectionId,
/// The collection's name
pub name: String,
/// The collection's overview
pub overview: String,
/// The list of movies that are part of this collection
#[serde(rename = "parts")]
pub movies: Vec<Item>,
}
/// A deserialized collection item from the TMDB API
#[derive(Debug, serde::Deserialize)]
pub struct Item {
/// The movie's TMDB ID
pub id: MovieId,
}
+14
View File
@@ -0,0 +1,14 @@
use chrono::NaiveDate;
/// A deserialized Episode from the TMDB API
#[derive(Debug, serde::Deserialize)]
pub struct Episode {
/// The episode's number
pub episode_number: i32,
/// The episode's name
pub name: String,
/// The episode's overview
pub overview: String,
/// The episode's air date
pub air_date: NaiveDate,
}
+19
View File
@@ -0,0 +1,19 @@
use super::id::{MovieGenreId, ShowGenreId};
/// A deserialized movie Genre from the TMDB API
#[derive(Debug, serde::Deserialize)]
pub struct MovieGenre {
/// The genre's TMDB ID
pub id: MovieGenreId,
/// The genre's name
pub name: String,
}
/// A deserialized show Genre from the TMDB API
#[derive(Debug, serde::Deserialize)]
pub struct ShowGenre {
/// The genre's TMDB ID
pub id: ShowGenreId,
/// The genre's name
pub name: String,
}
+79
View File
@@ -0,0 +1,79 @@
use core::fmt;
use core::marker::PhantomData;
/// The TMDB ID type of a movie genre
pub type MovieGenreId = TmdbId<MovieGenre>;
/// The TMDB ID type of a show genre
pub type ShowGenreId = TmdbId<ShowGenre>;
/// The TMDB ID type of a collection
pub type CollectionId = TmdbId<Collection>;
/// The TMDB ID type of a movie
pub type MovieId = TmdbId<Movie>;
/// The TMDB ID type of a show
pub type ShowId = TmdbId<Show>;
pub enum MovieGenre {}
pub enum ShowGenre {}
pub enum Collection {}
pub enum Movie {}
pub enum Show {}
type Inner = i32;
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(transparent)]
#[repr(transparent)]
pub struct TmdbId<T> {
inner: Inner,
#[serde(skip_serializing, default)]
_phantom: PhantomData<T>,
}
impl<T> TmdbId<T> {
pub fn inner(&self) -> Inner {
self.inner
}
}
impl<T> From<Inner> for TmdbId<T> {
fn from(value: Inner) -> Self {
Self {
inner: value,
_phantom: PhantomData,
}
}
}
impl<T> From<TmdbId<T>> for Inner {
fn from(value: TmdbId<T>) -> Self {
value.inner
}
}
impl<T> fmt::Debug for TmdbId<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.inner.fmt(f)
}
}
impl<T> fmt::Display for TmdbId<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.inner.fmt(f)
}
}
impl<T> Clone for TmdbId<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for TmdbId<T> {}
impl<T> PartialEq for TmdbId<T> {
fn eq(&self, other: &Self) -> bool {
self.inner == other.inner
}
}
impl<T> Eq for TmdbId<T> {}
+17
View File
@@ -0,0 +1,17 @@
mod collection;
mod episode;
mod genre;
mod id;
mod movie;
mod season;
mod show;
pub use collection::*;
pub use episode::*;
pub use genre::*;
pub use movie::*;
pub use season::*;
pub use serde::*;
pub use show::*;
pub use id::{CollectionId, MovieGenreId, MovieId, ShowGenreId, ShowId};
+53
View File
@@ -0,0 +1,53 @@
use chrono::NaiveDate;
use super::{CollectionId, MovieGenre, MovieId};
/// A deserialized Movie from the TMDB API
#[derive(Debug, serde::Deserialize)]
pub struct Movie {
/// The movie's TMDB ID
pub id: MovieId,
/// The movie's collection, if it exists
#[serde(rename = "belongs_to_collection")]
pub collection: Option<InCollection>,
/// The movie's title
pub title: String,
/// The movie's overview
pub overview: String,
/// The list of genres the movie belongs to
pub genres: Vec<MovieGenre>,
/// The movie's release date
pub release_date: NaiveDate,
/// The movie's status
pub status: MovieStatus,
}
/// A deserialized movie's collection from the TMDB API
#[derive(Debug, serde::Deserialize)]
pub struct InCollection {
/// The collection's TMDB ID
pub id: CollectionId,
}
/// A deserialized movie status from the TMDB API
#[derive(Debug, serde::Deserialize)]
pub enum MovieStatus {
/// The movie was cancelled
#[serde(rename = "Canceled")]
Canceled,
/// The movie is in production
#[serde(rename = "In Production")]
InProduction,
/// The movie is planned
#[serde(rename = "Planned")]
Planned,
/// The movie is in post production
#[serde(rename = "Post Production")]
PostProduction,
/// The movie is released
#[serde(rename = "Released")]
Released,
/// The movie is rumored
#[serde(rename = "Rumored")]
Rumored,
}
+18
View File
@@ -0,0 +1,18 @@
use chrono::NaiveDate;
use super::Episode;
/// A deserialized Season from the TMDB API
#[derive(Debug, serde::Deserialize)]
pub struct Season {
/// The season's number
pub season_number: i32,
/// The season's name
pub name: String,
/// The season's overview
pub overview: String,
/// The season's air date
pub air_date: NaiveDate,
/// The list of episodes in this season
pub episodes: Vec<Episode>,
}
+47
View File
@@ -0,0 +1,47 @@
use chrono::NaiveDate;
use super::{ShowGenre, ShowId};
/// A deserialized Show from the TMDB API
#[derive(Debug, serde::Deserialize)]
pub struct Show {
/// The show's TMDB ID
pub id: ShowId,
/// The show's name
pub name: String,
/// The show's overview
pub overview: String,
/// The list of genres this show belongs to
pub genres: Vec<ShowGenre>,
/// The show's first air date
pub first_air_date: NaiveDate,
/// The show's last air date
pub last_air_date: NaiveDate,
/// The number of seasons in this show
pub number_of_seasons: i32,
/// The show's status
pub status: ShowStatus,
}
/// A deserialized show Status from the TMDB API
#[derive(Debug, serde::Deserialize)]
pub enum ShowStatus {
/// The show is returning
#[serde(rename = "Returning Series")]
Returning,
/// The show is planned
#[serde(rename = "Planned")]
Planned,
/// The show is in procuction
#[serde(rename = "In Production")]
InProduction,
/// The show has ended
#[serde(rename = "Ended")]
Ended,
/// The show is canceled
#[serde(rename = "Canceled")]
Canceled,
/// The show only released a pilot
#[serde(rename = "Pilot")]
Pilot,
}