diff --git a/proxmox-async/src/compression.rs b/proxmox-async/src/compression.rs index e36f0d5e..68b73d59 100644 --- a/proxmox-async/src/compression.rs +++ b/proxmox-async/src/compression.rs @@ -80,7 +80,7 @@ impl DeflateEncoder { let old_out = self.compressor.total_out(); let res = self .compressor - .compress(&inbuf[..], self.buffer.get_free_mut_slice(), flush)?; + .compress(inbuf, self.buffer.get_free_mut_slice(), flush)?; let new_in = (self.compressor.total_in() - old_in) as usize; let new_out = (self.compressor.total_out() - old_out) as usize; self.buffer.add_size(new_out); diff --git a/proxmox-router/src/cli/command.rs b/proxmox-router/src/cli/command.rs index c66797a8..1b05078c 100644 --- a/proxmox-router/src/cli/command.rs +++ b/proxmox-router/src/cli/command.rs @@ -61,7 +61,7 @@ async fn handle_simple_command_future( let params = parse_arguments(prefix, cli_cmd, args)?; match cli_cmd.info.handler { - ApiHandler::Sync(handler) => match (handler)(params, &cli_cmd.info, &mut rpcenv) { + ApiHandler::Sync(handler) => match (handler)(params, cli_cmd.info, &mut rpcenv) { Ok(value) => { if value != Value::Null { println!("Result: {}", serde_json::to_string_pretty(&value).unwrap()); @@ -73,7 +73,7 @@ async fn handle_simple_command_future( } }, ApiHandler::Async(handler) => { - let future = (handler)(params, &cli_cmd.info, &mut rpcenv); + let future = (handler)(params, cli_cmd.info, &mut rpcenv); match future.await { Ok(value) => { @@ -107,7 +107,7 @@ fn handle_simple_command( let params = parse_arguments(prefix, cli_cmd, args)?; match cli_cmd.info.handler { - ApiHandler::Sync(handler) => match (handler)(params, &cli_cmd.info, &mut rpcenv) { + ApiHandler::Sync(handler) => match (handler)(params, cli_cmd.info, &mut rpcenv) { Ok(value) => { if value != Value::Null { println!("Result: {}", serde_json::to_string_pretty(&value).unwrap()); @@ -119,7 +119,7 @@ fn handle_simple_command( } }, ApiHandler::Async(handler) => { - let future = (handler)(params, &cli_cmd.info, &mut rpcenv); + let future = (handler)(params, cli_cmd.info, &mut rpcenv); if let Some(run) = run { match (run)(future) { Ok(value) => { @@ -172,7 +172,7 @@ fn parse_nested_command<'a>( }); let err_msg = format!("no command specified.\nPossible commands: {}", list); - print_nested_usage_error(&prefix, map, &err_msg); + print_nested_usage_error(prefix, map, &err_msg); return Err(format_err!("{}", err_msg)); } @@ -182,7 +182,7 @@ fn parse_nested_command<'a>( Some(cmd) => cmd, None => { let err_msg = format!("no such command '{}'", command); - print_nested_usage_error(&prefix, map, &err_msg); + print_nested_usage_error(prefix, map, &err_msg); return Err(format_err!("{}", err_msg)); } }; @@ -192,7 +192,7 @@ fn parse_nested_command<'a>( match sub_cmd { CommandLineInterface::Simple(cli_cmd) => { //return handle_simple_command(&prefix, cli_cmd, args).await; - return Ok(&cli_cmd); + return Ok(cli_cmd); } CommandLineInterface::Nested(new_map) => map = new_map, } @@ -297,12 +297,12 @@ pub async fn handle_command_future( let result = match &*def { CommandLineInterface::Simple(ref cli_cmd) => { - handle_simple_command_future(&prefix, &cli_cmd, args, rpcenv).await + handle_simple_command_future(prefix, cli_cmd, args, rpcenv).await } CommandLineInterface::Nested(ref map) => { let mut prefix = prefix.to_string(); - let cli_cmd = parse_nested_command(&mut prefix, &map, &mut args)?; - handle_simple_command_future(&prefix, &cli_cmd, args, rpcenv).await + let cli_cmd = parse_nested_command(&mut prefix, map, &mut args)?; + handle_simple_command_future(&prefix, cli_cmd, args, rpcenv).await } }; @@ -326,12 +326,12 @@ pub fn handle_command( let result = match &*def { CommandLineInterface::Simple(ref cli_cmd) => { - handle_simple_command(&prefix, &cli_cmd, args, rpcenv, run) + handle_simple_command(prefix, cli_cmd, args, rpcenv, run) } CommandLineInterface::Nested(ref map) => { let mut prefix = prefix.to_string(); - let cli_cmd = parse_nested_command(&mut prefix, &map, &mut args)?; - handle_simple_command(&prefix, &cli_cmd, args, rpcenv, run) + let cli_cmd = parse_nested_command(&mut prefix, map, &mut args)?; + handle_simple_command(&prefix, cli_cmd, args, rpcenv, run) } }; @@ -357,10 +357,10 @@ fn prepare_cli_command(def: &CommandLineInterface) -> (String, Vec) { if args[0] == "printdoc" { let usage = match def { CommandLineInterface::Simple(cli_cmd) => { - generate_usage_str(&prefix, &cli_cmd, DocumentationFormat::ReST, "", &[]) + generate_usage_str(&prefix, cli_cmd, DocumentationFormat::ReST, "", &[]) } CommandLineInterface::Nested(map) => { - generate_nested_usage(&prefix, &map, DocumentationFormat::ReST) + generate_nested_usage(&prefix, map, DocumentationFormat::ReST) } }; println!("{}", usage); diff --git a/proxmox-router/src/cli/completion.rs b/proxmox-router/src/cli/completion.rs index 42b19e5f..303ab406 100644 --- a/proxmox-router/src/cli/completion.rs +++ b/proxmox-router/src/cli/completion.rs @@ -67,7 +67,7 @@ fn get_property_completion( } Schema::Array(ArraySchema { items, .. }) => { if let Schema::String(_) = items { - return get_property_completion(&items, name, completion_functions, arg, param); + return get_property_completion(items, name, completion_functions, arg, param); } } _ => {} @@ -101,7 +101,7 @@ fn get_simple_completion( record_done_argument(done, cli_cmd.info.parameters, prop_name, &args[0]); if args.len() > 1 { if is_array_param { - return get_simple_completion(cli_cmd, done, &arg_param[..], &args[1..]); + return get_simple_completion(cli_cmd, done, arg_param, &args[1..]); } else { return get_simple_completion(cli_cmd, done, &arg_param[1..], &args[1..]); } @@ -153,7 +153,7 @@ fn get_simple_completion( schema, prop_name, &cli_cmd.completion_functions, - &prefix, + prefix, done, ); } @@ -223,9 +223,9 @@ impl CommandLineInterface { CommandLineInterface::Simple(cli_cmd) => { let mut done: HashMap = HashMap::new(); cli_cmd.fixed_param.iter().for_each(|(key, value)| { - record_done_argument(&mut done, cli_cmd.info.parameters, &key, &value); + record_done_argument(&mut done, cli_cmd.info.parameters, key, value); }); - get_simple_completion(cli_cmd, &mut done, &cli_cmd.arg_param, args) + get_simple_completion(cli_cmd, &mut done, cli_cmd.arg_param, args) } CommandLineInterface::Nested(map) => { if args.is_empty() { diff --git a/proxmox-router/src/cli/format.rs b/proxmox-router/src/cli/format.rs index c36f44bd..a84c0bc0 100644 --- a/proxmox-router/src/cli/format.rs +++ b/proxmox-router/src/cli/format.rs @@ -47,7 +47,7 @@ pub fn format_and_print_result_full( } else if output_format == "json" { println!("{}", serde_json::to_string(&result).unwrap()); } else if output_format == "text" { - if let Err(err) = value_to_text(std::io::stdout(), result, &return_type.schema, options) { + if let Err(err) = value_to_text(std::io::stdout(), result, return_type.schema, options) { eprintln!("unable to format result: {}", err); } } else { diff --git a/proxmox-router/src/cli/getopts.rs b/proxmox-router/src/cli/getopts.rs index e41766a8..8608f3a7 100644 --- a/proxmox-router/src/cli/getopts.rs +++ b/proxmox-router/src/cli/getopts.rs @@ -152,7 +152,7 @@ pub fn parse_arguments>( for i in 0..arg_param.len() { let name = arg_param[i]; - if let Some((optional, param_schema)) = schema.lookup(&name) { + if let Some((optional, param_schema)) = schema.lookup(name) { if i == arg_param.len() - 1 { last_arg_param_is_optional = optional; if let Schema::Array(_) = param_schema { @@ -250,7 +250,7 @@ fn test_argument_paramenter() { let args = vec!["-enable", "local"]; let res = parse_arguments( &args, - &vec!["storage"], + &["storage"], &HashMap::new(), ParameterSchema::from(&PARAMETERS), ); diff --git a/proxmox-router/src/cli/text_table.rs b/proxmox-router/src/cli/text_table.rs index 19320341..fd5f079e 100644 --- a/proxmox-router/src/cli/text_table.rs +++ b/proxmox-router/src/cli/text_table.rs @@ -476,7 +476,7 @@ fn format_table( let mut cells = Vec::new(); for entry in list.iter() { let result = if let Some(renderer) = renderer { - (renderer)(&entry[name], &entry) + (renderer)(&entry[name], entry) } else { data_to_text(&entry[name], prop_schema) }; @@ -691,7 +691,7 @@ fn format_object( }); let result = if let Some(renderer) = renderer { - (renderer)(&data[name], &data) + (renderer)(&data[name], data) } else { data_to_text(&data[name], prop_schema) }; diff --git a/proxmox-router/src/format.rs b/proxmox-router/src/format.rs index 32c1009f..9f805b3c 100644 --- a/proxmox-router/src/format.rs +++ b/proxmox-router/src/format.rs @@ -14,7 +14,7 @@ fn dump_method_definition(method: &str, path: &str, def: Option<&ApiMethod>) -> match def { None => None, Some(api_method) => { - let description = wrap_text("", "", &api_method.parameters.description(), 80); + let description = wrap_text("", "", api_method.parameters.description(), 80); let param_descr = dump_properties(&api_method.parameters, "", style, &[]); let return_descr = dump_api_return_schema(&api_method.returns, style); diff --git a/proxmox-router/src/permission.rs b/proxmox-router/src/permission.rs index eb93b332..f2e9d469 100644 --- a/proxmox-router/src/permission.rs +++ b/proxmox-router/src/permission.rs @@ -96,7 +96,7 @@ pub fn check_api_permission( param: &HashMap, info: &dyn UserInformation, ) -> bool { - if let Some(ref userid) = userid { + if let Some(userid) = userid { if info.is_superuser(userid) { return true; } @@ -120,7 +120,7 @@ fn check_api_permission_tail( } Permission::Superuser => match userid { None => return false, - Some(ref userid) => return info.is_superuser(userid), + Some(userid) => return info.is_superuser(userid), }, Permission::User(expected_userid) => match userid { None => return false, @@ -133,7 +133,7 @@ fn check_api_permission_tail( }, Permission::Group(expected_group) => match userid { None => return false, - Some(ref userid) => return info.is_group_member(userid, expected_group), + Some(userid) => return info.is_group_member(userid, expected_group), }, Permission::WithParam(param_name, subtest) => { return check_api_permission( diff --git a/proxmox-router/src/rpc_environment.rs b/proxmox-router/src/rpc_environment.rs index 27c71984..7f7d7f9b 100644 --- a/proxmox-router/src/rpc_environment.rs +++ b/proxmox-router/src/rpc_environment.rs @@ -60,14 +60,14 @@ pub enum RpcEnvironmentType { impl core::ops::Index<&str> for &dyn RpcEnvironment { type Output = Value; fn index(&self, index: &str) -> &Value { - &self.result_attrib().index(index) + self.result_attrib().index(index) } } impl core::ops::Index<&str> for &mut dyn RpcEnvironment { type Output = Value; fn index(&self, index: &str) -> &Value { - &self.result_attrib().index(index) + self.result_attrib().index(index) } } diff --git a/proxmox-schema/src/format.rs b/proxmox-schema/src/format.rs index 104b1c08..95cb76ce 100644 --- a/proxmox-schema/src/format.rs +++ b/proxmox-schema/src/format.rs @@ -113,12 +113,12 @@ pub fn dump_properties( let mut optional_list: Vec = Vec::new(); for (prop, optional, schema) in param.properties() { - if skip.iter().find(|n| n == &prop).is_some() { + if skip.iter().any(|n| n == prop) { continue; } let mut param_descr = - get_property_description(prop, &schema, style, DocumentationFormat::ReST); + get_property_description(prop, schema, style, DocumentationFormat::ReST); if !indent.is_empty() { param_descr = format!("{}{}", indent, param_descr); // indent first line diff --git a/proxmox-schema/src/schema.rs b/proxmox-schema/src/schema.rs index 5e6e8185..44f19984 100644 --- a/proxmox-schema/src/schema.rs +++ b/proxmox-schema/src/schema.rs @@ -885,7 +885,7 @@ pub fn parse_property_string(value_str: &str, schema: &'static Schema) -> Result .collect(); for value in list { - match parse_simple_value(value.trim(), &array_schema.items) { + match parse_simple_value(value.trim(), array_schema.items) { Ok(res) => array.push(res), Err(err) => bail!("unable to parse array element: {}", err), } @@ -951,7 +951,7 @@ fn do_parse_parameter_strings( let additional_properties = schema.additional_properties(); for (key, value) in data { - if let Some((_optional, prop_schema)) = schema.lookup(&key) { + if let Some((_optional, prop_schema)) = schema.lookup(key) { match prop_schema { Schema::Array(array_schema) => { if params[key] == Value::Null { @@ -959,7 +959,7 @@ fn do_parse_parameter_strings( } match params[key] { Value::Array(ref mut array) => { - match parse_simple_value(value, &array_schema.items) { + match parse_simple_value(value, array_schema.items) { Ok(res) => array.push(res), // fixme: check_length?? Err(err) => errors.push(key.into(), err), } @@ -1031,11 +1031,11 @@ pub fn verify_json(data: &Value, schema: &Schema) -> Result<(), Error> { } } Schema::Object(object_schema) => verify_json_object(data, object_schema)?, - Schema::Array(array_schema) => verify_json_array(data, &array_schema)?, - Schema::Boolean(boolean_schema) => verify_json_boolean(data, &boolean_schema)?, - Schema::Integer(integer_schema) => verify_json_integer(data, &integer_schema)?, - Schema::Number(number_schema) => verify_json_number(data, &number_schema)?, - Schema::String(string_schema) => verify_json_string(data, &string_schema)?, + Schema::Array(array_schema) => verify_json_array(data, array_schema)?, + Schema::Boolean(boolean_schema) => verify_json_boolean(data, boolean_schema)?, + Schema::Integer(integer_schema) => verify_json_integer(data, integer_schema)?, + Schema::Number(number_schema) => verify_json_number(data, number_schema)?, + Schema::String(string_schema) => verify_json_string(data, string_schema)?, Schema::AllOf(all_of_schema) => verify_json_object(data, all_of_schema)?, } Ok(()) @@ -1087,7 +1087,7 @@ pub fn verify_json_array(data: &Value, schema: &ArraySchema) -> Result<(), Error schema.check_length(list.len())?; for (i, item) in list.iter().enumerate() { - let result = verify_json(item, &schema.items); + let result = verify_json(item, schema.items); if let Err(err) = result { let mut errors = ParameterError::new(); errors.add_errors(&format!("[{}]", i), err); @@ -1111,7 +1111,7 @@ pub fn verify_json_object(data: &Value, schema: &dyn ObjectSchemaType) -> Result let additional_properties = schema.additional_properties(); for (key, value) in map { - if let Some((_optional, prop_schema)) = schema.lookup(&key) { + if let Some((_optional, prop_schema)) = schema.lookup(key) { let result = match prop_schema { Schema::Object(object_schema) => verify_json_object(value, object_schema), Schema::Array(array_schema) => verify_json_array(value, array_schema), diff --git a/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs index 36c63cc7..592c203e 100644 --- a/proxmox-section-config/src/lib.rs +++ b/proxmox-section-config/src/lib.rs @@ -66,7 +66,7 @@ impl SectionConfigPlugin { pub fn get_id_schema(&self) -> Option<&Schema> { match &self.id_property { Some(id_prop) => { - if let Some((_, schema)) = self.properties.lookup(&id_prop) { + if let Some((_, schema)) = self.properties.lookup(id_prop) { Some(schema) } else { None @@ -325,7 +325,7 @@ impl SectionConfig { let plugin = self.plugins.get(type_name).unwrap(); let id_schema = plugin.get_id_schema().unwrap_or(self.id_schema); - if let Err(err) = parse_simple_value(§ion_id, &id_schema) { + if let Err(err) = parse_simple_value(section_id, id_schema) { bail!("syntax error in section identifier: {}", err.to_string()); } if section_id.chars().any(|c| c.is_control()) { @@ -402,7 +402,7 @@ impl SectionConfig { (self.parse_section_header)(line) { //println!("OKLINE: type: {} ID: {}", section_type, section_id); - if let Some(ref plugin) = self.plugins.get(§ion_type) { + if let Some(plugin) = self.plugins.get(§ion_type) { let id_schema = plugin.get_id_schema().unwrap_or(self.id_schema); if let Err(err) = parse_simple_value(§ion_id, id_schema) { @@ -480,12 +480,12 @@ impl SectionConfig { if let ParseState::InsideSection(plugin, ref mut section_id, ref mut config) = state { // finish section - test_required_properties(&config, plugin.properties, &plugin.id_property)?; + test_required_properties(config, plugin.properties, &plugin.id_property)?; if let Some(id_property) = &plugin.id_property { config[id_property] = Value::from(section_id.clone()); } - result.set_data(§ion_id, &plugin.type_name, config)?; - result.record_order(§ion_id); + result.set_data(section_id, &plugin.type_name, config)?; + result.record_order(section_id); } Ok(()) @@ -756,7 +756,7 @@ lvmthin: local-lvm2 content rootdir,images "; - let res = config.parse(filename, &raw); + let res = config.parse(filename, raw); println!("RES: {:?}", res); let raw = config.write(filename, &res.unwrap()); println!("CONFIG:\n{}", raw.unwrap()); @@ -827,7 +827,7 @@ group: mygroup comment a very important group "; - let res = config.parse(filename, &raw); + let res = config.parse(filename, raw); println!("RES: {:?}", res); let raw = config.write(filename, &res.unwrap()); println!("CONFIG:\n{}", raw.unwrap()); @@ -876,7 +876,7 @@ lvmthin: local-lvm2 thinpool data "; - let res = config.parse(filename, &raw); + let res = config.parse(filename, raw); println!("RES: {:?}", res); let created = config .write(filename, &res.unwrap())