From 0aa3f574a597c0a5e535786fdd985f8ceb95586a Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 29 Jan 2023 11:57:59 -0600 Subject: [PATCH] Clippy --- src/config/primitives.rs | 12 ++++++------ src/init_tracing.rs | 2 +- src/processor.rs | 10 +++++----- src/queue.rs | 4 ++-- src/queue/cleanup.rs | 4 ++-- src/queue/process.rs | 8 ++------ src/repo.rs | 14 +++++++------- src/repo/old.rs | 6 +++--- src/store/object_store.rs | 2 +- 9 files changed, 29 insertions(+), 33 deletions(-) diff --git a/src/config/primitives.rs b/src/config/primitives.rs index 6e2be94..f2179fe 100644 --- a/src/config/primitives.rs +++ b/src/config/primitives.rs @@ -200,7 +200,7 @@ impl Display for Targets { let targets = self .targets .iter() - .map(|(path, level)| format!("{}={}", path, level)) + .map(|(path, level)| format!("{path}={level}")) .collect::>() .join(","); @@ -226,12 +226,12 @@ impl Display for Targets { if let Some(level) = max_level { if !targets.is_empty() { - write!(f, "{},{}", level, targets) + write!(f, "{level},{targets}") } else { - write!(f, "{}", level) + write!(f, "{level}") } } else if !targets.is_empty() { - write!(f, "{}", targets) + write!(f, "{targets}") } else { Ok(()) } @@ -246,7 +246,7 @@ impl FromStr for ImageFormat { "jpeg" | "jpg" => Ok(Self::Jpeg), "png" => Ok(Self::Png), "webp" => Ok(Self::Webp), - other => Err(format!("Invalid variant: {}", other)), + other => Err(format!("Invalid variant: {other}")), } } } @@ -260,7 +260,7 @@ impl FromStr for LogFormat { return Ok(*variant); } } - Err(format!("Invalid variant: {}", s)) + Err(format!("Invalid variant: {s}")) } } diff --git a/src/init_tracing.rs b/src/init_tracing.rs index 695a02e..62bfe74 100644 --- a/src/init_tracing.rs +++ b/src/init_tracing.rs @@ -41,7 +41,7 @@ where .with(ErrorLayer::default()); if let Some(address) = tracing.console.address { - println!("Starting console on {}", address); + println!("Starting console on {address}"); let console_layer = ConsoleLayer::builder() .event_buffer_capacity(tracing.console.buffer_capacity) diff --git a/src/processor.rs b/src/processor.rs index 19c14af..c649ca0 100644 --- a/src/processor.rs +++ b/src/processor.rs @@ -81,8 +81,8 @@ impl ResizeKind { fn to_magick_string(self) -> String { match self { - Self::Area(size) => format!("{}@>", size), - Self::Bounds(size) => format!("{}x{}>", size, size), + Self::Area(size) => format!("{size}@>"), + Self::Bounds(size) => format!("{size}x{size}>"), } } } @@ -207,21 +207,21 @@ impl Processor for Resize { filter: None, kind: ResizeKind::Area(size), } => { - let node = format!(".a{}", size); + let node = format!(".a{size}"); path.push(node); } Resize { filter: Some(filter), kind: ResizeKind::Bounds(size), } => { - let node = format!("{}.{}", filter.to_magick_str(), size); + let node = format!("{}.{size}", filter.to_magick_str()); path.push(node); } Resize { filter: Some(filter), kind: ResizeKind::Area(size), } => { - let node = format!("{}.a{}", filter.to_magick_str(), size); + let node = format!("{}.a{size}", filter.to_magick_str()); path.push(node); } } diff --git a/src/queue.rs b/src/queue.rs index 9195010..ca48bd1 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -190,8 +190,8 @@ async fn process_jobs( let res = job_loop(repo, store, worker_id.clone(), queue, callback).await; if let Err(e) = res { - tracing::warn!("Error processing jobs: {}", format!("{}", e)); - tracing::warn!("{}", format!("{:?}", e)); + tracing::warn!("Error processing jobs: {}", format!("{e}")); + tracing::warn!("{}", format!("{e:?}")); continue; } diff --git a/src/queue/cleanup.rs b/src/queue/cleanup.rs index 891b326..7beb5ff 100644 --- a/src/queue/cleanup.rs +++ b/src/queue/cleanup.rs @@ -42,7 +42,7 @@ where Cleanup::AllVariants => all_variants::(repo).await?, }, Err(e) => { - tracing::warn!("Invalid job: {}", format!("{}", e)); + tracing::warn!("Invalid job: {}", format!("{e}")); } } @@ -72,7 +72,7 @@ where let span = tracing::error_span!("Error deleting files"); span.in_scope(|| { for error in errors { - tracing::error!("{}", format!("{}", error)); + tracing::error!("{}", format!("{error}")); } }); } diff --git a/src/queue/process.rs b/src/queue/process.rs index ab854b9..034fbc8 100644 --- a/src/queue/process.rs +++ b/src/queue/process.rs @@ -58,7 +58,7 @@ where } }, Err(e) => { - tracing::warn!("Invalid job: {}", format!("{}", e)); + tracing::warn!("Invalid job: {}", format!("{e}")); } } @@ -113,11 +113,7 @@ where result } Err(e) => { - tracing::warn!( - "Failed to ingest {}, {}", - format!("{}", e), - format!("{:?}", e) - ); + tracing::warn!("Failed to ingest {}, {}", format!("{e}"), format!("{e:?}")); UploadResult::Failure { message: e.to_string(), diff --git a/src/repo.rs b/src/repo.rs index 4b5a937..c1e8b0f 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -486,7 +486,7 @@ impl Repo { async { for hash in old.hashes() { if let Err(e) = migrate_hash(repo, &old, hash).await { - tracing::error!("Failed to migrate hash: {}", format!("{:?}", e)); + tracing::error!("Failed to migrate hash: {}", format!("{e:?}")); } } @@ -529,7 +529,7 @@ impl Repo { if let Err(e) = migrate_identifiers_for_hash(repo, hash).await { tracing::error!( "Failed to migrate identifiers for hash: {}", - format!("{:?}", e) + format!("{e:?}") ); } } @@ -831,8 +831,8 @@ impl std::fmt::Display for UploadId { impl std::fmt::Display for MaybeUuid { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::Uuid(id) => write!(f, "{}", id), - Self::Name(name) => write!(f, "{}", name), + Self::Uuid(id) => write!(f, "{id}"), + Self::Name(name) => write!(f, "{name}"), } } } @@ -862,7 +862,7 @@ impl std::str::FromStr for Alias { impl std::fmt::Display for Alias { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if let Some(ext) = self.extension() { - write!(f, "{}{}", self.id, ext) + write!(f, "{}{ext}", self.id) } else { write!(f, "{}", self.id) } @@ -1001,7 +1001,7 @@ mod tests { fn uuid_string_alias_ext() { let uuid = Uuid::new_v4(); - let alias_str = format!("{}.mp4", uuid); + let alias_str = format!("{uuid}.mp4"); let alias = Alias::from_existing(&alias_str); assert_eq!( @@ -1091,7 +1091,7 @@ mod tests { fn uuid_bytes_string_alias_ext() { let uuid = Uuid::new_v4(); - let alias_str = format!("{}.mp4", uuid); + let alias_str = format!("{uuid}.mp4"); let alias = Alias::from_slice(alias_str.as_bytes()).unwrap(); assert_eq!( diff --git a/src/repo/old.rs b/src/repo/old.rs index 3f892b2..7fe1a27 100644 --- a/src/repo/old.rs +++ b/src/repo/old.rs @@ -123,7 +123,7 @@ impl Old { let filename_string = String::from_utf8_lossy(&filename); - let variant_prefix = format!("{}/", filename_string); + let variant_prefix = format!("{filename_string}/"); Ok(self .identifier_tree @@ -157,7 +157,7 @@ impl Old { let filename_string = String::from_utf8_lossy(&filename); - let motion_key = format!("{}/motion", filename_string); + let motion_key = format!("{filename_string}/motion"); Ok(self.filename_tree.get(motion_key)?) } @@ -175,7 +175,7 @@ impl Old { } pub(super) fn delete_token(&self, alias: &Alias) -> color_eyre::Result> { - let key = format!("{}/delete", alias); + let key = format!("{alias}/delete"); if let Some(ivec) = self.alias_tree.get(key)? { return Ok(DeleteToken::from_slice(&ivec)); diff --git a/src/store/object_store.rs b/src/store/object_store.rs index 8c8be47..7a483de 100644 --- a/src/store/object_store.rs +++ b/src/store/object_store.rs @@ -611,7 +611,7 @@ impl ObjectStore { let path = self.next_directory().await?.to_strings().join("/"); let filename = uuid::Uuid::new_v4().to_string(); - Ok(format!("{}/{}", path, filename)) + Ok(format!("{path}/{filename}")) } }