diff --git a/proxmox-api/src/api_type.rs b/proxmox-api/src/api_type.rs index afb4d385..8599a6ff 100644 --- a/proxmox-api/src/api_type.rs +++ b/proxmox-api/src/api_type.rs @@ -72,6 +72,8 @@ impl Parameter { } } +pub type ParseCliFn = fn(name: &str, value: Option<&str>) -> Result; + /// Bare type info. Types themselves should also have a description, even if a method's parameter /// usually overrides it. Ideally we can hyperlink the parameter to the type information in the /// generated documentation. @@ -79,7 +81,7 @@ pub struct TypeInfo { pub name: &'static str, pub description: &'static str, pub complete_fn: Option, - pub parse_cli: Option) -> Result>, + pub parse_cli: Option, } impl TypeInfo { diff --git a/proxmox-api/src/cli.rs b/proxmox-api/src/cli.rs index 5969de15..1b321ac8 100644 --- a/proxmox-api/src/cli.rs +++ b/proxmox-api/src/cli.rs @@ -110,6 +110,7 @@ pub struct SubCommands { commands: HashMap<&'static str, Command>, } +#[allow(clippy::new_without_default)] impl SubCommands { /// Create a new empty SubCommands hash. pub fn new() -> Self { @@ -246,6 +247,7 @@ impl Method { } } +#[allow(clippy::enum_variant_names)] enum Arg<'a> { Positional(&'a str), Opt(&'a str), @@ -389,7 +391,7 @@ impl ParseCli for String { } } -impl ParseCli for HashSet { +impl ParseCli for HashSet { fn parse_cli(name: &str, value: Option<&str>) -> Result { Ok(serde_json::Value::Array( value diff --git a/proxmox-api/src/router.rs b/proxmox-api/src/router.rs index 4fbdbbe6..b011a96e 100644 --- a/proxmox-api/src/router.rs +++ b/proxmox-api/src/router.rs @@ -103,7 +103,7 @@ where .get_or_insert_with(serde_json::Map::new) .insert( param_name.to_string(), - Value::String(matched_wildcard.unwrap_or(String::new())), + Value::String(matched_wildcard.unwrap_or_else(String::new)), ); }