diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/Cargo.toml | 2 | ||||
-rw-r--r-- | common/src/helpers.rs | 10 | ||||
-rw-r--r-- | common/src/lib.rs | 10 | ||||
-rw-r--r-- | common/src/user.rs | 12 |
4 files changed, 20 insertions, 14 deletions
diff --git a/common/Cargo.toml b/common/Cargo.toml index 3c8d90a..913be45 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -serde = { version = "1.0.197", features = ["derive"] } +serde = { version = "1.0.203", features = ["derive"] } bincode = { version = "2.0.0-rc.3", features = ["derive"] } rocket = { workspace = true, optional = true } chrono = { version = "0.4.38", features = ["serde"] } diff --git a/common/src/helpers.rs b/common/src/helpers.rs index 92595e0..54f5479 100644 --- a/common/src/helpers.rs +++ b/common/src/helpers.rs @@ -5,15 +5,21 @@ */ use std::ops::Deref; -#[derive(PartialEq, PartialOrd)] +#[derive(PartialEq)] pub struct SortAnyway<T>(pub T); impl<T: PartialEq> Eq for SortAnyway<T> { fn assert_receiver_is_total_eq(&self) {} } +#[allow(clippy::non_canonical_partial_ord_impl)] +impl<T: PartialOrd> PartialOrd for SortAnyway<T> { + fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { + self.0.partial_cmp(&other.0) + } +} impl<T: PartialOrd> Ord for SortAnyway<T> { fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.partial_cmp(&other).unwrap() + self.partial_cmp(other).unwrap() } } diff --git a/common/src/lib.rs b/common/src/lib.rs index d06c40c..7403347 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -3,6 +3,7 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2024 metamuffin <metamuffin.org> */ +#![allow(clippy::needless_borrows_for_generic_args)] pub mod config; pub mod helpers; pub mod r#impl; @@ -282,17 +283,16 @@ impl TraktKind { } } } -impl ToString for TraktKind { - fn to_string(&self) -> String { - match self { +impl Display for TraktKind { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(match self { TraktKind::Movie => "Movie", TraktKind::Show => "Show", TraktKind::Season => "Season", TraktKind::Episode => "Episode", TraktKind::Person => "Person", TraktKind::User => "User", - } - .to_string() + }) } } impl Display for ObjectIds { diff --git a/common/src/user.rs b/common/src/user.rs index 5f2b0e4..1a527b9 100644 --- a/common/src/user.rs +++ b/common/src/user.rs @@ -129,19 +129,19 @@ impl UserPermission { impl Display for UserPermission { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(&match self { - UserPermission::ManageSelf => format!("manage self (password, display name, etc.)"), - UserPermission::FederatedContent => format!("access to federated content"), - UserPermission::Admin => format!("administrative rights"), + UserPermission::ManageSelf => "manage self (password, display name, etc.)".to_string(), + UserPermission::FederatedContent => "access to federated content".to_string(), + UserPermission::Admin => "administrative rights".to_string(), UserPermission::StreamFormat(StreamFormat::Original) => { - format!("downloading the original media") + "downloading the original media".to_string() } UserPermission::StreamFormat(StreamFormat::Matroska) => { - format!("downloading a remuxed WebM/Matroska version of the media ") + "downloading a remuxed WebM/Matroska version of the media ".to_string() } UserPermission::StreamFormat(x) => { format!("downloading media via {x:?}") } - UserPermission::Transcode => format!("transcoding"), + UserPermission::Transcode => "transcoding".to_string(), // UserPermission::ManageUsers => format!("management of all users"), // UserPermission::GenerateInvite => format!("inviting new users"), UserPermission::AccessNode(s) => format!("access to library node {s:?}"), |