Skip to content

Commit 5cd0cae

Browse files
CodingAnarchyclaude
andcommitted
style: Apply cargo fmt formatting
- Auto-formatting applied to maintain code style consistency 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 84d730f commit 5cd0cae

File tree

3 files changed

+40
-38
lines changed

3 files changed

+40
-38
lines changed

examples/key_management_example.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
//! - Use external key management service configuration
1010
1111
use chrono::Duration;
12-
use hammerwork::encryption::{
13-
ExternalKmsConfig, KeyDerivationConfig, KeyManagerConfig,
14-
};
12+
use hammerwork::encryption::{ExternalKmsConfig, KeyDerivationConfig, KeyManagerConfig};
1513
use std::collections::HashMap;
1614

1715
#[tokio::main]

src/job.rs

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,13 @@ impl Type<Postgres> for JobStatus {
7272

7373
#[cfg(feature = "postgres")]
7474
impl Encode<'_, Postgres> for JobStatus {
75-
fn encode_by_ref(&self, buf: &mut sqlx::postgres::PgArgumentBuffer) -> Result<sqlx::encode::IsNull, Box<dyn std::error::Error + Send + Sync + 'static>> {
75+
fn encode_by_ref(
76+
&self,
77+
buf: &mut sqlx::postgres::PgArgumentBuffer,
78+
) -> Result<sqlx::encode::IsNull, Box<dyn std::error::Error + Send + Sync + 'static>> {
7679
let status_str = match self {
7780
JobStatus::Pending => "Pending",
78-
JobStatus::Running => "Running",
81+
JobStatus::Running => "Running",
7982
JobStatus::Completed => "Completed",
8083
JobStatus::Failed => "Failed",
8184
JobStatus::Dead => "Dead",
@@ -116,11 +119,14 @@ impl Type<MySql> for JobStatus {
116119

117120
#[cfg(feature = "mysql")]
118121
impl Encode<'_, MySql> for JobStatus {
119-
fn encode_by_ref(&self, buf: &mut Vec<u8>) -> Result<sqlx::encode::IsNull, Box<dyn std::error::Error + Send + Sync + 'static>> {
122+
fn encode_by_ref(
123+
&self,
124+
buf: &mut Vec<u8>,
125+
) -> Result<sqlx::encode::IsNull, Box<dyn std::error::Error + Send + Sync + 'static>> {
120126
let status_str = match self {
121127
JobStatus::Pending => "Pending",
122128
JobStatus::Running => "Running",
123-
JobStatus::Completed => "Completed",
129+
JobStatus::Completed => "Completed",
124130
JobStatus::Failed => "Failed",
125131
JobStatus::Dead => "Dead",
126132
JobStatus::TimedOut => "TimedOut",
@@ -2280,8 +2286,12 @@ mod tests {
22802286
"Archived" => JobStatus::Archived,
22812287
_ => panic!("Unknown job status: {}", input),
22822288
};
2283-
2284-
assert_eq!(*expected, parsed_status, "Failed to parse '{}' correctly", input);
2289+
2290+
assert_eq!(
2291+
*expected, parsed_status,
2292+
"Failed to parse '{}' correctly",
2293+
input
2294+
);
22852295
}
22862296
}
22872297

@@ -2311,12 +2321,24 @@ mod tests {
23112321
JobStatus::Retrying => "Retrying",
23122322
JobStatus::Archived => "Archived",
23132323
};
2314-
2315-
assert_eq!(*expected_str, encoded_str, "Encoding mismatch for {:?}", status);
2316-
2324+
2325+
assert_eq!(
2326+
*expected_str, encoded_str,
2327+
"Encoding mismatch for {:?}",
2328+
status
2329+
);
2330+
23172331
// Verify the encoded string does not have quotes
2318-
assert!(!encoded_str.starts_with('"'), "Encoded string should not start with quotes: {}", encoded_str);
2319-
assert!(!encoded_str.ends_with('"'), "Encoded string should not end with quotes: {}", encoded_str);
2332+
assert!(
2333+
!encoded_str.starts_with('"'),
2334+
"Encoded string should not start with quotes: {}",
2335+
encoded_str
2336+
);
2337+
assert!(
2338+
!encoded_str.ends_with('"'),
2339+
"Encoded string should not end with quotes: {}",
2340+
encoded_str
2341+
);
23202342
}
23212343
}
23222344
}

src/queue/postgres.rs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -965,35 +965,17 @@ impl DatabaseQueue for crate::queue::JobQueue<Postgres> {
965965
counts.insert(status, count as u64);
966966
}
967967

968-
let pending_count = counts
969-
.get("Pending")
970-
.copied()
971-
.unwrap_or(0);
972-
let running_count = counts
973-
.get("Running")
974-
.copied()
975-
.unwrap_or(0);
976-
let dead_count = counts
977-
.get("Dead")
978-
.copied()
979-
.unwrap_or(0);
980-
let timed_out_count = counts
981-
.get("TimedOut")
982-
.copied()
983-
.unwrap_or(0);
984-
let completed_count = counts
985-
.get("Completed")
986-
.copied()
987-
.unwrap_or(0);
968+
let pending_count = counts.get("Pending").copied().unwrap_or(0);
969+
let running_count = counts.get("Running").copied().unwrap_or(0);
970+
let dead_count = counts.get("Dead").copied().unwrap_or(0);
971+
let timed_out_count = counts.get("TimedOut").copied().unwrap_or(0);
972+
let completed_count = counts.get("Completed").copied().unwrap_or(0);
988973

989974
// Basic statistics (more detailed stats would require the statistics collector)
990975
let statistics = JobStatistics {
991976
total_processed: completed_count + dead_count,
992977
completed: completed_count,
993-
failed: counts
994-
.get("Failed")
995-
.copied()
996-
.unwrap_or(0),
978+
failed: counts.get("Failed").copied().unwrap_or(0),
997979
dead: dead_count,
998980
timed_out: timed_out_count,
999981
running: running_count,

0 commit comments

Comments
 (0)