Skip to content

Commit

Permalink
fmt + clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
PetoMPP committed Feb 13, 2024
1 parent 555fa0e commit 95b991b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 41 deletions.
12 changes: 6 additions & 6 deletions src/controllers/user_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ impl Controller for UserSettingsController {
}

#[get("/")]
async fn get<'a>(
pool: &'a dyn UserSettingsRepo,
) -> Result<Json<ApiResponse<'a, UserSettingsDto>>, ApiError<'a>> {
async fn get(
pool: &dyn UserSettingsRepo,
) -> Result<Json<ApiResponse<UserSettingsDto>>, ApiError> {
let settings = pool.get()?;
Ok(Json(ApiResponse::ok(settings.into())))
}

#[post("/", data = "<settings>")]
async fn update<'a>(
async fn update(
_claims: AdminClaims,
settings: Json<UserSettingsDto>,
pool: &'a dyn UserSettingsRepo,
) -> Result<Json<ApiResponse<'a, UserSettingsDto>>, ApiError<'a>> {
pool: &dyn UserSettingsRepo,
) -> Result<Json<ApiResponse<UserSettingsDto>>, ApiError> {
let settings = pool.update(&settings.into_inner().into())?;
Ok(Json(ApiResponse::ok(settings.into())))
}
10 changes: 5 additions & 5 deletions src/models/resource_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ pub struct Resource {
pub pl: Option<String>,
}

impl Into<ResourceData> for Resource {
fn into(self) -> ResourceData {
impl From<Resource> 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,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/models/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ impl Display for Role {
}
}

impl Into<RoleData> for Role {
fn into(self) -> RoleData {
match self {
impl From<Role> for RoleData {
fn from(val: Role) -> Self {
match val {
Role::User => RoleData::User,
Role::Admin => RoleData::Admin,
}
Expand Down
16 changes: 8 additions & 8 deletions src/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ impl User {
}
}

impl Into<UserData> for User {
fn into(self) -> UserData {
impl From<User> 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,
}
}
}
22 changes: 11 additions & 11 deletions src/models/user_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ impl From<UserSettingsDto> for UserSettings {
}
}

impl Into<UserSettingsDto> for UserSettings {
fn into(self) -> UserSettingsDto {
impl From<UserSettings> 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,
}
}
}
2 changes: 1 addition & 1 deletion src/repositories/user_settings/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod repo;
pub mod repo;
6 changes: 1 addition & 5 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,);
4 changes: 2 additions & 2 deletions src/services/azure_blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -128,7 +128,7 @@ impl AzureBlobService for ClientBuilder {
meta: BlobMetaDto,
data: &[u8],
) -> Result<String, Error> {
let filename = match meta.filename.ends_with("/") {
let filename = match meta.filename.ends_with('/') {
true => format!(
"{}{}{}",
meta.filename,
Expand Down

0 comments on commit 95b991b

Please sign in to comment.