From 3bf397aac20bae9add6e6e9e0542b35aabcf8773 Mon Sep 17 00:00:00 2001 From: Erin Power Date: Tue, 25 Jan 2022 11:58:15 +0100 Subject: [PATCH] fmt --- src/filters/capture.rs | 3 ++- src/filters/capture/config.rs | 29 ++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/filters/capture.rs b/src/filters/capture.rs index cd803a217..3c291817f 100644 --- a/src/filters/capture.rs +++ b/src/filters/capture.rs @@ -71,7 +71,8 @@ impl Filter for Capture { #[cfg_attr(feature = "instrument", tracing::instrument(skip(self, ctx)))] fn read(&self, mut ctx: ReadContext) -> Option { let capture = self.capture.capture(&mut ctx.contents, &self.metrics); - ctx.metadata.insert(self.is_present_key.clone(), Value::Bool(capture.is_some())); + ctx.metadata + .insert(self.is_present_key.clone(), Value::Bool(capture.is_some())); if let Some(value) = capture { ctx.metadata.insert(self.metadata_key.clone(), value); diff --git a/src/filters/capture/config.rs b/src/filters/capture/config.rs index 8094f9c8c..7be3d6e4a 100644 --- a/src/filters/capture/config.rs +++ b/src/filters/capture/config.rs @@ -76,12 +76,12 @@ impl Serialize for Config { impl<'de> serde::Deserialize<'de> for Config { fn deserialize(deserializer: D) -> Result where - D: serde::Deserializer<'de> + D: serde::Deserializer<'de>, { #[derive(Deserialize)] #[serde(field_identifier, rename_all = "lowercase")] enum Field { - #[serde(rename="metadataKey")] + #[serde(rename = "metadataKey")] MetadataKey, Prefix, Suffix, @@ -103,13 +103,17 @@ impl<'de> serde::Deserialize<'de> for Config { { let mut metadata_key = None; let mut strategy = None; - let strategy_exists_err = || Err(serde::de::Error::custom("Multiple strategies found, only one capture strategy is permitted")); + let strategy_exists_err = || { + Err(serde::de::Error::custom( + "Multiple strategies found, only one capture strategy is permitted", + )) + }; while let Some(key) = map.next_key()? { match key { Field::MetadataKey => { if metadata_key.is_some() { - return Err(serde::de::Error::duplicate_field("metadataKey")) + return Err(serde::de::Error::duplicate_field("metadataKey")); } metadata_key = Some(map.next_value()?); @@ -117,7 +121,7 @@ impl<'de> serde::Deserialize<'de> for Config { Field::Prefix => { if strategy.is_some() { - return (strategy_exists_err)() + return (strategy_exists_err)(); } strategy = Some(Strategy::Prefix(map.next_value()?)); @@ -125,7 +129,7 @@ impl<'de> serde::Deserialize<'de> for Config { Field::Suffix => { if strategy.is_some() { - return (strategy_exists_err)() + return (strategy_exists_err)(); } strategy = Some(Strategy::Suffix(map.next_value()?)); @@ -133,7 +137,7 @@ impl<'de> serde::Deserialize<'de> for Config { Field::Regex => { if strategy.is_some() { - return (strategy_exists_err)() + return (strategy_exists_err)(); } strategy = Some(Strategy::Regex(map.next_value()?)); @@ -142,9 +146,16 @@ impl<'de> serde::Deserialize<'de> for Config { } let metadata_key = metadata_key.unwrap_or_else(|| CAPTURED_BYTES.into()); - let strategy = strategy.ok_or_else(|| serde::de::Error::custom("Capture strategy of `regex`, `suffix`, or `prefix` is required"))?; + let strategy = strategy.ok_or_else(|| { + serde::de::Error::custom( + "Capture strategy of `regex`, `suffix`, or `prefix` is required", + ) + })?; - Ok(Config { metadata_key, strategy }) + Ok(Config { + metadata_key, + strategy, + }) } }