Skip to content

Commit

Permalink
Merge pull request #48 from ansg191/compact_str
Browse files Browse the repository at this point in the history
feat: switches from `smol_str` to `compact_str`
  • Loading branch information
ansg191 authored Mar 2, 2024
2 parents 36962cf + 43d9c8f commit 5c9a200
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion trakt-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ default = []
[dependencies]
bitflags = "2.4"
bytes = { workspace = true }
compact_str = { version = "0.7", features = ["serde"] }
http = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
smol_str = { version = "0.2", features = ["serde"] }
time = { workspace = true }
trakt-core = { workspace = true }
trakt-macros = { workspace = true }
Expand Down
8 changes: 4 additions & 4 deletions trakt-rs/src/api/certifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub mod list {
use std::collections::HashMap;

use compact_str::CompactString;
use serde::Serialize;
use smol_str::SmolStr;

use crate::smo::Country;

Expand All @@ -35,8 +35,8 @@ pub mod list {

#[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Deserialize)]
pub struct Certification {
pub name: SmolStr,
pub slug: SmolStr,
pub description: String,
pub name: CompactString,
pub slug: CompactString,
pub description: CompactString,
}
}
4 changes: 2 additions & 2 deletions trakt-rs/src/api/country.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pub mod list {
//!
//! <https://trakt.docs.apiary.io/#reference/countries/list/get-countries>
use compact_str::CompactString;
use serde::{Deserialize, Serialize};
use smol_str::SmolStr;

use crate::smo::Country;

Expand All @@ -33,7 +33,7 @@ pub mod list {

#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
pub struct ResponseItem {
pub name: SmolStr,
pub name: CompactString,
pub code: Country,
}
}
6 changes: 3 additions & 3 deletions trakt-rs/src/api/genres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pub mod list {
//!
//! <https://trakt.docs.apiary.io/#reference/genres/list/get-genres>
use compact_str::CompactString;
use serde::{Deserialize, Serialize};
use smol_str::SmolStr;

#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, trakt_macros::Request)]
#[trakt(
Expand All @@ -31,7 +31,7 @@ pub mod list {

#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
pub struct ResponseItem {
pub name: SmolStr,
pub slug: SmolStr,
pub name: CompactString,
pub slug: CompactString,
}
}
24 changes: 12 additions & 12 deletions trakt-rs/src/smo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
mod de;
mod ser;

use compact_str::CompactString;
use serde::{Deserialize, Serialize};
use smol_str::SmolStr;
use time::{Date, OffsetDateTime};
use trakt_core::EmojiString;

#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize)]
#[serde(untagged)]
pub enum Id {
Trakt(u64),
Slug(SmolStr),
Slug(CompactString),
Tvdb(u64),
Imdb(SmolStr),
Imdb(CompactString),
Tmdb(u64),
}

Expand All @@ -37,25 +37,25 @@ pub struct Ids {
#[serde(skip_serializing_if = "Option::is_none")]
pub trakt: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub slug: Option<SmolStr>,
pub slug: Option<CompactString>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tvdb: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub imdb: Option<SmolStr>,
pub imdb: Option<CompactString>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tmdb: Option<u64>,
}

#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct Movie {
pub title: String,
pub title: CompactString,
pub year: u16,
pub ids: Ids,
}

#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct Show {
pub title: String,
pub title: CompactString,
pub year: u16,
pub ids: Ids,
}
Expand All @@ -70,21 +70,21 @@ pub struct Season {
pub struct Episode {
pub season: u16,
pub number: u16,
pub title: String,
pub title: CompactString,
pub ids: Ids,
}

#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct Person {
pub name: String,
pub name: CompactString,
pub ids: Ids,
}

#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct User {
pub username: String,
pub username: CompactString,
pub private: bool,
pub name: String,
pub name: CompactString,
pub vip: bool,
pub vip_ep: bool,
pub ids: Ids,
Expand Down Expand Up @@ -254,7 +254,7 @@ pub struct Distribution(pub [u32; 10]);

#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize)]
pub struct Studio {
pub name: String,
pub name: CompactString,
pub country: Country,
pub ids: Ids,
}
Expand Down

0 comments on commit 5c9a200

Please sign in to comment.