Skip to content

Commit 046f702

Browse files
committed
backend: fix cargo clippy + fmt
1 parent 3593ec7 commit 046f702

File tree

6 files changed

+39
-18
lines changed

6 files changed

+39
-18
lines changed

backend/src/branding.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
/// Branding configuration for the application
2-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
33
pub enum Brand {
4+
#[default]
45
Warp,
56
Seb,
67
}
78

89
impl Brand {
910
/// Parse brand from environment variable or string
1011
pub fn from_env() -> Self {
12+
use std::str::FromStr;
13+
1114
std::env::var("BRAND")
1215
.ok()
13-
.and_then(|s| Self::from_str(&s))
16+
.and_then(|s| Self::from_str(&s).ok())
1417
.unwrap_or(Brand::Warp)
1518
}
19+
}
20+
21+
impl std::str::FromStr for Brand {
22+
type Err = ();
1623

17-
/// Parse brand from string
18-
pub fn from_str(s: &str) -> Option<Self> {
24+
fn from_str(s: &str) -> Result<Self, Self::Err> {
1925
match s.to_lowercase().as_str() {
20-
"seb" => Some(Brand::Seb),
21-
"warp" => Some(Brand::Warp),
22-
_ => None,
26+
"seb" => Ok(Brand::Seb),
27+
"warp" => Ok(Brand::Warp),
28+
_ => Err(()),
2329
}
2430
}
2531
}
26-
27-
impl Default for Brand {
28-
fn default() -> Self {
29-
Brand::Warp
30-
}
31-
}

backend/src/routes/auth/register.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ use utoipa::ToSchema;
3232
use validator::Validate;
3333

3434
use crate::{
35-
AppState, branding, error::Error, routes::auth::VERIFICATION_EXPIRATION_DAYS, utils::{self, get_connection}
35+
branding,
36+
error::Error,
37+
routes::auth::VERIFICATION_EXPIRATION_DAYS,
38+
utils::{self, get_connection},
39+
AppState,
3640
};
3741

3842
#[derive(Template)]

backend/src/routes/auth/resend_verification.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ use serde::{Deserialize, Serialize};
66
use utoipa::ToSchema;
77

88
use crate::{
9-
AppState, branding, error::Error, routes::auth::VERIFICATION_EXPIRATION_DAYS, utils::{get_connection, web_block_unpacked}
9+
branding,
10+
error::Error,
11+
routes::auth::VERIFICATION_EXPIRATION_DAYS,
12+
utils::{get_connection, web_block_unpacked},
13+
AppState,
1014
};
1115

1216
use db_connector::models::{users::User, verification::Verification};

backend/src/routes/auth/start_recovery.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ use utoipa::IntoParams;
77
use uuid::Uuid;
88

99
use crate::{
10-
AppState, branding, error::Error, routes::user::{get_user, get_user_id}, utils::{self, get_connection, web_block_unpacked}
10+
branding,
11+
error::Error,
12+
routes::user::{get_user, get_user_id},
13+
utils::{self, get_connection, web_block_unpacked},
14+
AppState,
1115
};
1216

1317
#[derive(Deserialize, IntoParams)]

backend/src/routes/send_chargelog_to_user.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ use std::io::Read;
66
use utoipa::ToSchema;
77

88
use crate::{
9-
AppState, branding, error::Error, rate_limit::ChargerRateLimiter, routes::{charger::add::password_matches, user::get_user}, utils::{get_charger_from_db, parse_uuid, send_email_with_attachment}
9+
branding,
10+
error::Error,
11+
rate_limit::ChargerRateLimiter,
12+
routes::{charger::add::password_matches, user::get_user},
13+
utils::{get_charger_from_db, parse_uuid, send_email_with_attachment},
14+
AppState,
1015
};
1116

1217
#[derive(Serialize, Deserialize, ToSchema)]

backend/src/routes/user/update_user.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
*/
1919

2020
use crate::{
21-
AppState, branding, error::Error, routes::auth::VERIFICATION_EXPIRATION_DAYS, utils::{get_connection, send_email, web_block_unpacked}
21+
branding,
22+
error::Error,
23+
routes::auth::VERIFICATION_EXPIRATION_DAYS,
24+
utils::{get_connection, send_email, web_block_unpacked},
25+
AppState,
2226
};
2327
use actix_web::{error::ErrorConflict, put, web, HttpResponse, Responder};
2428
use askama::Template;

0 commit comments

Comments
 (0)