From 95b991b7c902f174a7578a00b7ec368ec11f6114 Mon Sep 17 00:00:00 2001 From: PetoMPP Date: Tue, 13 Feb 2024 17:16:05 +0100 Subject: [PATCH] fmt + clippy --- src/controllers/user_settings.rs | 12 ++++++------ src/models/resource_data.rs | 10 +++++----- src/models/role.rs | 6 +++--- src/models/user.rs | 16 ++++++++-------- src/models/user_settings.rs | 22 +++++++++++----------- src/repositories/user_settings/mod.rs | 2 +- src/schema.rs | 6 +----- src/services/azure_blob.rs | 4 ++-- 8 files changed, 37 insertions(+), 41 deletions(-) diff --git a/src/controllers/user_settings.rs b/src/controllers/user_settings.rs index 680d6f5..35ae8b6 100644 --- a/src/controllers/user_settings.rs +++ b/src/controllers/user_settings.rs @@ -19,19 +19,19 @@ impl Controller for UserSettingsController { } #[get("/")] -async fn get<'a>( - pool: &'a dyn UserSettingsRepo, -) -> Result>, ApiError<'a>> { +async fn get( + pool: &dyn UserSettingsRepo, +) -> Result>, ApiError> { let settings = pool.get()?; Ok(Json(ApiResponse::ok(settings.into()))) } #[post("/", data = "")] -async fn update<'a>( +async fn update( _claims: AdminClaims, settings: Json, - pool: &'a dyn UserSettingsRepo, -) -> Result>, ApiError<'a>> { + pool: &dyn UserSettingsRepo, +) -> Result>, ApiError> { let settings = pool.update(&settings.into_inner().into())?; Ok(Json(ApiResponse::ok(settings.into()))) } diff --git a/src/models/resource_data.rs b/src/models/resource_data.rs index a5abca4..bd99f91 100644 --- a/src/models/resource_data.rs +++ b/src/models/resource_data.rs @@ -11,12 +11,12 @@ pub struct Resource { pub pl: Option, } -impl Into for Resource { - fn into(self) -> ResourceData { +impl From for ResourceData { + fn from(val: Resource) -> Self { ResourceData { - key: self.key.unwrap(), - en: self.en, - pl: self.pl, + key: val.key.unwrap(), + en: val.en, + pl: val.pl, } } } diff --git a/src/models/role.rs b/src/models/role.rs index 10fa41e..92b84e1 100644 --- a/src/models/role.rs +++ b/src/models/role.rs @@ -52,9 +52,9 @@ impl Display for Role { } } -impl Into for Role { - fn into(self) -> RoleData { - match self { +impl From for RoleData { + fn from(val: Role) -> Self { + match val { Role::User => RoleData::User, Role::Admin => RoleData::Admin, } diff --git a/src/models/user.rs b/src/models/user.rs index 72ecad4..c4d68b1 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -33,15 +33,15 @@ impl User { } } -impl Into for User { - fn into(self) -> UserData { +impl From for UserData { + fn from(val: User) -> Self { UserData { - id: self.id.unwrap(), - name: self.name.0.clone(), - role: self.role.into(), - confirmed: self.confirmed, - created_at: self.created_at.unwrap(), - deleted_at: self.deleted_at, + id: val.id.unwrap(), + name: val.name.0.clone(), + role: val.role.into(), + confirmed: val.confirmed, + created_at: val.created_at.unwrap(), + deleted_at: val.deleted_at, } } } diff --git a/src/models/user_settings.rs b/src/models/user_settings.rs index 27bfe00..1c42b00 100644 --- a/src/models/user_settings.rs +++ b/src/models/user_settings.rs @@ -44,18 +44,18 @@ impl From for UserSettings { } } -impl Into for UserSettings { - fn into(self) -> UserSettingsDto { +impl From for UserSettingsDto { + fn from(val: UserSettings) -> Self { UserSettingsDto { - name_min_length: self.name_min_length, - name_max_length: self.name_max_length, - name_special_characters: self.name_special_characters, - password_min_length: self.password_min_length, - password_needed_checks: self.password_needed_checks, - password_check_numbers: self.password_check_numbers, - password_check_uppercase: self.password_check_uppercase, - password_check_lowercase: self.password_check_lowercase, - password_check_special_characters: self.password_check_special_characters, + name_min_length: val.name_min_length, + name_max_length: val.name_max_length, + name_special_characters: val.name_special_characters, + password_min_length: val.password_min_length, + password_needed_checks: val.password_needed_checks, + password_check_numbers: val.password_check_numbers, + password_check_uppercase: val.password_check_uppercase, + password_check_lowercase: val.password_check_lowercase, + password_check_special_characters: val.password_check_special_characters, } } } diff --git a/src/repositories/user_settings/mod.rs b/src/repositories/user_settings/mod.rs index 35eb3df..c426b23 100644 --- a/src/repositories/user_settings/mod.rs +++ b/src/repositories/user_settings/mod.rs @@ -1 +1 @@ -pub mod repo; \ No newline at end of file +pub mod repo; diff --git a/src/schema.rs b/src/schema.rs index a4b3953..c5c8c49 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -42,8 +42,4 @@ diesel::table! { } } -diesel::allow_tables_to_appear_in_same_query!( - resources, - user_settings, - users, -); +diesel::allow_tables_to_appear_in_same_query!(resources, user_settings, users,); diff --git a/src/services/azure_blob.rs b/src/services/azure_blob.rs index 9a556da..d152609 100644 --- a/src/services/azure_blob.rs +++ b/src/services/azure_blob.rs @@ -42,7 +42,7 @@ impl AzureBlobService for ClientBuilder { for blob in resp? .blobs .blobs() - .filter(|b| &b.name == &filename) + .filter(|b| b.name == filename) .cloned() { versions.push(blob); @@ -128,7 +128,7 @@ impl AzureBlobService for ClientBuilder { meta: BlobMetaDto, data: &[u8], ) -> Result { - let filename = match meta.filename.ends_with("/") { + let filename = match meta.filename.ends_with('/') { true => format!( "{}{}{}", meta.filename,