router: rustfmt

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-04-10 12:40:39 +02:00
parent 0ec1c684ae
commit 05cad8926b
8 changed files with 20 additions and 16 deletions

View File

@ -3,8 +3,8 @@ use serde_json::Value;
use std::cell::RefCell;
use std::sync::Arc;
use proxmox_schema::*;
use proxmox_schema::format::DocumentationFormat;
use proxmox_schema::*;
use super::environment::CliEnvironment;
use super::getopts;

View File

@ -86,7 +86,7 @@ fn get_simple_completion(
let prop_name = arg_param[0];
if let Some((optional, schema)) = cli_cmd.info.parameters.lookup(prop_name) {
let is_array_param = matches!(schema, Schema::Array(_));
if (optional || is_array_param) && args[0].starts_with('-') {
// argument parameter is optional (or array) , and arg
// looks like an option, so assume its empty and

View File

@ -1,5 +1,5 @@
use std::path::PathBuf;
use std::collections::HashMap;
use std::path::PathBuf;
use nix::dir::Dir;
use nix::fcntl::{AtFlags, OFlag};
@ -21,11 +21,10 @@ pub fn complete_file_name(arg: &str, _param: &HashMap<String, String>) -> Vec<St
}
}
let mut dir =
match Dir::openat(libc::AT_FDCWD, &dirname, OFlag::O_DIRECTORY, Mode::empty()) {
Ok(d) => d,
Err(_) => return result,
};
let mut dir = match Dir::openat(libc::AT_FDCWD, &dirname, OFlag::O_DIRECTORY, Mode::empty()) {
Ok(d) => d,
Err(_) => return result,
};
for entry in dir.iter().flatten() {
if let Ok(name) = entry.file_name().to_str() {
@ -35,8 +34,7 @@ pub fn complete_file_name(arg: &str, _param: &HashMap<String, String>) -> Vec<St
let mut newpath = dirname.clone();
newpath.push(name);
if let Ok(stat) = fstatat(libc::AT_FDCWD, &newpath, AtFlags::empty())
{
if let Ok(stat) = fstatat(libc::AT_FDCWD, &newpath, AtFlags::empty()) {
if (stat.st_mode & libc::S_IFMT) == libc::S_IFDIR {
newpath.push("");
if let Some(newpath) = newpath.to_str() {

View File

@ -4,10 +4,10 @@ use std::collections::HashSet;
use serde_json::Value;
use proxmox_schema::*;
use proxmox_schema::format::{
get_property_description, get_schema_type_text, DocumentationFormat, ParameterDisplayStyle,
};
use proxmox_schema::*;
use super::{value_to_text, TableFormatOptions};
use super::{CliCommand, CliCommandMap, CommandLineInterface};

View File

@ -74,7 +74,7 @@ pub(crate) fn parse_argument_list<T: AsRef<str>>(
None => {
let mut want_bool = false;
let mut can_default = false;
if let Some((_optional, Schema::Boolean(boolean_schema))) = schema.lookup(&name) {
if let Some((_opt, Schema::Boolean(boolean_schema))) = schema.lookup(&name) {
want_bool = true;
match boolean_schema.default {
Some(false) | None => can_default = true,

View File

@ -446,7 +446,10 @@ fn format_table<W: Write>(
None => bail!("property {} does not exist in schema.", name),
};
let is_numeric = matches!(prop_schema, Schema::Integer(_) | Schema::Number(_) | Schema::Boolean(_));
let is_numeric = matches!(
prop_schema,
Schema::Integer(_) | Schema::Number(_) | Schema::Boolean(_)
);
let (header, right_align, renderer) = options.lookup_column_info(name);
@ -645,7 +648,10 @@ fn format_object<W: Write>(
None => bail!("property {} does not exist in schema.", name),
};
let is_numeric = matches!(prop_schema, Schema::Integer(_) | Schema::Number(_) | Schema::Boolean(_));
let is_numeric = matches!(
prop_schema,
Schema::Integer(_) | Schema::Number(_) | Schema::Boolean(_)
);
let (header, right_align, renderer) = options.lookup_column_info(name);

View File

@ -73,7 +73,7 @@ pub trait UserInformation {
fn lookup_privs(&self, userid: &str, path: &[&str]) -> u64;
}
impl <T: UserInformation> UserInformation for std::sync::Arc<T> {
impl<T: UserInformation> UserInformation for std::sync::Arc<T> {
fn is_superuser(&self, userid: &str) -> bool {
self.deref().is_superuser(userid)
}

View File

@ -218,7 +218,7 @@ macro_rules! list_subdirs_api_method {
/// # use serde_json::{json, Value};
/// use proxmox_router::{ApiHandler, ApiMethod, Router};
/// use proxmox_schema::ObjectSchema;
///
///
/// const API_METHOD_HELLO: ApiMethod = ApiMethod::new(
/// &ApiHandler::Sync(&|_, _, _| {
/// Ok(json!("Hello world!"))