Skip to content

Commit 3cf3c43

Browse files
committed
backend: fix clippy and fmt
1 parent 1c01d72 commit 3cf3c43

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

backend/src/routes/send_chargelog_to_user.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use utoipa::ToSchema;
66
use crate::{
77
error::Error,
88
rate_limit::ChargerRateLimiter,
9-
routes::{charger::add::{get_charger_from_db, password_matches}, user::get_user},
9+
routes::{
10+
charger::add::{get_charger_from_db, password_matches},
11+
user::get_user,
12+
},
1013
utils::{parse_uuid, send_email_with_attachment},
1114
AppState,
1215
};
@@ -38,14 +41,16 @@ pub async fn send_chargelog(
3841
let mut bytes = web::BytesMut::new();
3942
while let Some(chunk) = payload.next().await {
4043
let chunk = chunk.map_err(|_| Error::InternalError)?;
41-
let chunk = chunk.into_iter().filter(|b| *b != b'\r' && *b != b'\n').collect::<Vec<u8>>();
44+
let chunk = chunk
45+
.into_iter()
46+
.filter(|b| *b != b'\r' && *b != b'\n')
47+
.collect::<Vec<u8>>();
4248
bytes.extend_from_slice(&chunk);
4349
}
44-
let payload: SendChargelogSchema = serde_json::from_slice(&bytes)
45-
.map_err(|err| {
46-
log::error!("Failed to parse payload: {}", err);
47-
Error::InvalidPayload
48-
})?;
50+
let payload: SendChargelogSchema = serde_json::from_slice(&bytes).map_err(|err| {
51+
log::error!("Failed to parse payload: {err}");
52+
Error::InvalidPayload
53+
})?;
4954

5055
rate_limiter.check(payload.charger_uuid.clone(), &req)?;
5156

@@ -90,7 +95,9 @@ mod tests {
9095
let payload = SendChargelogSchema {
9196
charger_uuid: charger.uuid.clone(),
9297
password: charger.password.clone(),
93-
user_uuid: crate::routes::user::tests::get_test_uuid(&user.mail).unwrap().to_string(),
98+
user_uuid: crate::routes::user::tests::get_test_uuid(&user.mail)
99+
.unwrap()
100+
.to_string(),
94101
filename: "chargelog.pdf".to_string(),
95102
chargelog: vec![1, 2, 3, 4, 5],
96103
};
@@ -116,7 +123,9 @@ mod tests {
116123
let payload = SendChargelogSchema {
117124
charger_uuid: charger.uuid.clone(),
118125
password: "wrongpassword".to_string(),
119-
user_uuid: crate::routes::user::tests::get_test_uuid(&user.mail).unwrap().to_string(),
126+
user_uuid: crate::routes::user::tests::get_test_uuid(&user.mail)
127+
.unwrap()
128+
.to_string(),
120129
filename: "chargelog.pdf".to_string(),
121130
chargelog: vec![1, 2, 3, 4, 5],
122131
};

backend/src/utils.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ pub fn send_email_with_attachment(
247247
let _ = attachment_data;
248248
let _ = attachment_filename;
249249
println!(
250-
"Test mode: Email would be sent to {} with subject '{}' and attachment {}",
251-
email, subject, attachment_filename
250+
"Test mode: Email would be sent to {email} with subject '{subject}' and attachment {attachment_filename}"
252251
);
253252
}
254253
}

0 commit comments

Comments
 (0)