]> git.proxmox.com Git - proxmox-backup.git/commitdiff
more clippy fixups
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 11 Sep 2019 10:23:11 +0000 (12:23 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 11 Sep 2019 10:23:12 +0000 (12:23 +0200)
mostly indentation changes, view with `-w`

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/api_schema/format.rs
src/api_schema/schema.rs
src/client/http_client.rs

index e4277bd7173b08b0df6b85fb49d17ecfd2e12603..2af0be8533128ac19529f004666566730927af7c 100644 (file)
@@ -51,8 +51,7 @@ pub fn wrap_text(initial_indent: &str, subsequent_indent: &str, text: &str, colu
 }
 
 pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> String {
-
-    let type_text = match schema {
+    match schema {
         Schema::Null => String::from("<null>"), // should not happen
         Schema::String(_) => String::from("<string>"),
         Schema::Boolean(_) => String::from("<boolean>"),
@@ -66,9 +65,7 @@ pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> S
        },
         Schema::Object(_) => String::from("<object>"),
         Schema::Array(_) => String::from("<array>"),
-    };
-
-    type_text
+    }
 }
 
 pub fn get_property_description(
@@ -229,14 +226,14 @@ fn dump_api_return_schema(schema: &Schema) -> String {
 fn dump_method_definition(method: &str, path: &str, def: &MethodDefinition) -> Option<String> {
 
     match def {
-        MethodDefinition::None => return None,
+        MethodDefinition::None => None,
         MethodDefinition::Simple(simple_method) => {
             let param_descr = dump_api_parameters(&simple_method.parameters);
 
             let return_descr = dump_api_return_schema(&simple_method.returns);
 
             let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr);
-            return Some(res);
+            Some(res)
          }
         MethodDefinition::Async(async_method) => {
             let method = if method == "POST" { "UPLOAD" } else { method };
@@ -247,7 +244,7 @@ fn dump_method_definition(method: &str, path: &str, def: &MethodDefinition) -> O
             let return_descr = dump_api_return_schema(&async_method.returns);
 
             let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr);
-            return Some(res);
+            Some(res)
         }
     }
 }
index 38d9a44bb8b228b59bc0090aaa73165d49259295..a7875575d108b66b7cc7a91a8680c16166602f75 100644 (file)
@@ -417,12 +417,10 @@ fn parse_property_string(value_str: &str, schema: &Schema) -> Result<Value, Erro
                 let kv: Vec<&str> = key_val.splitn(2, '=').collect();
                 if kv.len() == 2 {
                     param_list.push((kv[0].into(), kv[1].into()));
+                } else if let Some(key) = object_schema.default_key {
+                    param_list.push((key.into(), kv[0].into()));
                 } else {
-                    if let Some(key) = object_schema.default_key {
-                        param_list.push((key.into(), kv[0].into()));
-                    } else {
-                        bail!("Value without key, but schema does not define a default key.");
-                    }
+                    bail!("Value without key, but schema does not define a default key.");
                 }
             }
 
@@ -511,24 +509,22 @@ pub fn parse_parameter_strings(data: &Vec<(String, String)>, schema: &ObjectSche
                     }
                 }
             }
-        } else {
-            if additional_properties {
-                match params[key] {
-                    Value::Null => {
-                        params[key] = Value::String(value.to_owned());
-                    },
-                    Value::String(ref old) => {
-                        params[key] = Value::Array(
-                            vec![Value::String(old.to_owned()),  Value::String(value.to_owned())]);
-                    }
-                    Value::Array(ref mut array) => {
-                        array.push(Value::String(value.to_string()));
-                    }
-                    _ => errors.push(format_err!("parameter '{}': expected array - type missmatch", key)),
+        } else if additional_properties {
+            match params[key] {
+                Value::Null => {
+                    params[key] = Value::String(value.to_owned());
+                },
+                Value::String(ref old) => {
+                    params[key] = Value::Array(
+                        vec![Value::String(old.to_owned()),  Value::String(value.to_owned())]);
                 }
-            } else {
-                errors.push(format_err!("parameter '{}': schema does not allow additional properties.", key));
+                Value::Array(ref mut array) => {
+                    array.push(Value::String(value.to_string()));
+                }
+                _ => errors.push(format_err!("parameter '{}': expected array - type missmatch", key)),
             }
+        } else {
+            errors.push(format_err!("parameter '{}': schema does not allow additional properties.", key));
         }
     }
 
@@ -638,10 +634,8 @@ pub fn verify_json_object(data: &Value, schema: &ObjectSchema) -> Result<(), Err
                 }
                 _ => verify_json(value, prop_schema)?,
             }
-        } else {
-            if !additional_properties {
-                bail!("property '{}': schema does not allow additional properties.", key);
-            }
+        } else if !additional_properties {
+            bail!("property '{}': schema does not allow additional properties.", key);
         }
     }
 
index b3d5d7799e5e356a80f15a8b430ab2c1c469469e..85b71ffc1b39ead09c25593d12770446650c49e7 100644 (file)
@@ -494,7 +494,7 @@ impl Drop for BackupReader {
 impl BackupReader {
 
     pub fn new(h2: H2Client, canceller: Canceller) -> Arc<Self> {
-        Arc::new(Self { h2, canceller: canceller })
+        Arc::new(Self { h2, canceller })
     }
 
     pub async fn get(