diff --git a/api-test/src/lxc/schema/mod.rs b/api-test/src/lxc/schema/mod.rs index c5cf9e66..b934562d 100644 --- a/api-test/src/lxc/schema/mod.rs +++ b/api-test/src/lxc/schema/mod.rs @@ -42,12 +42,7 @@ pub enum ConsoleMode { pub mod mount_options { pub const NAME: &'static str = "mount options"; - const VALID_MOUNT_OPTIONS: &[&'static str] = &[ - "noatime", - "nodev", - "noexec", - "nosuid", - ]; + const VALID_MOUNT_OPTIONS: &[&'static str] = &["noatime", "nodev", "noexec", "nosuid"]; pub fn verify(value: &T) -> bool { value.all(|s| VALID_MOUNT_OPTIONS.contains(&s)) diff --git a/api-test/src/schema/mod.rs b/api-test/src/schema/mod.rs index 16417648..62e74918 100644 --- a/api-test/src/schema/mod.rs +++ b/api-test/src/schema/mod.rs @@ -73,10 +73,7 @@ pub mod safe_path { pub fn verify(value: &T) -> bool { value.all(|s| { - s != ".." - && !s.starts_with("../") - && !s.ends_with("/..") - && !s.contains("/../") + s != ".." && !s.starts_with("../") && !s.ends_with("/..") && !s.contains("/../") }) } } diff --git a/api-test/src/schema/string_list.rs b/api-test/src/schema/string_list.rs index f49ee557..3aac603d 100644 --- a/api-test/src/schema/string_list.rs +++ b/api-test/src/schema/string_list.rs @@ -62,7 +62,9 @@ impl<'de> serde::de::Visitor<'de> for StringListVisitor { } fn visit_seq>(self, mut seq: A) -> Result { - let mut out = seq.size_hint().map_or_else(Vec::new, |size| Vec::with_capacity(size)); + let mut out = seq + .size_hint() + .map_or_else(Vec::new, |size| Vec::with_capacity(size)); loop { match seq.next_element::()? { Some(el) => out.push(el), diff --git a/api-test/src/schema/string_set.rs b/api-test/src/schema/string_set.rs index 0d68c153..891287ec 100644 --- a/api-test/src/schema/string_set.rs +++ b/api-test/src/schema/string_set.rs @@ -33,7 +33,10 @@ where value .for_each_str(|s| { if s.contains(';') { - bail!("cannot include value \"{}\" in a semicolon separated list", s); + bail!( + "cannot include value \"{}\" in a semicolon separated list", + s + ); } if !data.is_empty() { diff --git a/api-test/src/schema/tools.rs b/api-test/src/schema/tools.rs index 2909fb4a..376ea2e3 100644 --- a/api-test/src/schema/tools.rs +++ b/api-test/src/schema/tools.rs @@ -33,7 +33,9 @@ impl StringContainer for Vec { impl StringContainer for Option> { fn all bool>(&self, pred: F) -> bool { - self.as_ref().map(|c| StringContainer::all(c, pred)).unwrap_or(true) + self.as_ref() + .map(|c| StringContainer::all(c, pred)) + .unwrap_or(true) } } @@ -45,6 +47,8 @@ impl StringContainer for HashSet { impl StringContainer for Option> { fn all bool>(&self, pred: F) -> bool { - self.as_ref().map(|c| StringContainer::all(c, pred)).unwrap_or(true) + self.as_ref() + .map(|c| StringContainer::all(c, pred)) + .unwrap_or(true) } } diff --git a/proxmox-api-macro/src/router_macro.rs b/proxmox-api-macro/src/router_macro.rs index fd9133a7..400b395f 100644 --- a/proxmox-api-macro/src/router_macro.rs +++ b/proxmox-api-macro/src/router_macro.rs @@ -337,10 +337,8 @@ fn parse_path_name(tokens: &mut TokenIter) -> Result { if group.delimiter() != Delimiter::Brace { bail!("invalid path component: {:?}", group); } - let name = need_hyphenated_name( - group.span(), - &mut group.stream().into_iter().peekable(), - )?; + let name = + need_hyphenated_name(group.span(), &mut group.stream().into_iter().peekable())?; push_component(&mut path, &mut component, &mut span); path.push(Component::Match(name)); diff --git a/proxmox-api/src/cli.rs b/proxmox-api/src/cli.rs index b4395531..d8227276 100644 --- a/proxmox-api/src/cli.rs +++ b/proxmox-api/src/cli.rs @@ -385,13 +385,14 @@ impl ParseCli for String { impl ParseCli for HashSet { fn parse_cli(name: &str, value: Option<&str>) -> Result { - Ok(serde_json::Value::Array(value - .ok_or_else(|| format_err!("missing value for parameter '{}'", name))? - .split(';') - .fold(Vec::new(), |mut list, entry| { - list.push(serde_json::Value::String(entry.trim().to_string())); - list - }) + Ok(serde_json::Value::Array( + value + .ok_or_else(|| format_err!("missing value for parameter '{}'", name))? + .split(';') + .fold(Vec::new(), |mut list, entry| { + list.push(serde_json::Value::String(entry.trim().to_string())); + list + }), )) } } diff --git a/proxmox-tools/src/common_regex.rs b/proxmox-tools/src/common_regex.rs index fcf43653..0841a9bb 100644 --- a/proxmox-tools/src/common_regex.rs +++ b/proxmox-tools/src/common_regex.rs @@ -5,18 +5,23 @@ use lazy_static::lazy_static; use regex::Regex; +#[rustfmt::skip] #[macro_export] macro_rules! IPV4OCTET { () => (r"(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9])?[0-9])") } +#[rustfmt::skip] #[macro_export] macro_rules! IPV6H16 { () => (r"(?:[0-9a-fA-F]{1,4})") } +#[rustfmt::skip] #[macro_export] macro_rules! IPV6LS32 { () => (concat!(r"(?:(?:", IPV4RE!(), "|", IPV6H16!(), ":", IPV6H16!(), "))" )) } /// Returns the regular expression string to match IPv4 addresses +#[rustfmt::skip] #[macro_export] macro_rules! IPV4RE { () => (concat!(r"(?:(?:", IPV4OCTET!(), r"\.){3}", IPV4OCTET!(), ")")) } /// Returns the regular expression string to match IPv6 addresses +#[rustfmt::skip] #[macro_export] macro_rules! IPV6RE { () => (concat!(r"(?:", r"(?:(?:", r"(?:", IPV6H16!(), r":){6})", IPV6LS32!(), r")|", @@ -31,17 +36,13 @@ macro_rules! IPV6RE { () => (concat!(r"(?:", } /// Returns the regular expression string to match IP addresses (v4 or v6) +#[rustfmt::skip] #[macro_export] macro_rules! IPRE { () => (concat!(r"(?:", IPV4RE!(), "|", IPV6RE!(), ")")) } lazy_static! { pub static ref IP_REGEX: Regex = Regex::new(IPRE!()).unwrap(); - - pub static ref SHA256_HEX_REGEX: Regex = - Regex::new(r"^[a-f0-9]{64}$") - .unwrap(); - + pub static ref SHA256_HEX_REGEX: Regex = Regex::new(r"^[a-f0-9]{64}$").unwrap(); pub static ref SYSTEMD_DATETIME_REGEX: Regex = - Regex::new(r"^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$") - .unwrap(); + Regex::new(r"^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$").unwrap(); }