From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id E1F991FF13B for ; Tue, 27 Jan 2026 10:14:40 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0A6961D5E4; Tue, 27 Jan 2026 10:15:04 +0100 (CET) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Mon, 26 Jan 2026 16:13:46 +0100 Message-ID: <20260126151349.627829-10-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260126151349.627829-1-m.sandoval@proxmox.com> References: <20260126151349.627829-1-m.sandoval@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1769440366964 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.160 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_EU 0.5 Prevalent use of .eu in spam/malware SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record X-Mailman-Approved-At: Tue, 27 Jan 2026 10:15:03 +0100 Subject: [pbs-devel] [PATCH proxmox 09/10] cargo: run fmt with 2024 style X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Signed-off-by: Maximiliano Sandoval --- pbs-api-types/src/acl.rs | 4 +- pbs-api-types/src/ad.rs | 4 +- pbs-api-types/src/crypto.rs | 2 +- pbs-api-types/src/datastore.rs | 18 +-- pbs-api-types/src/jobs.rs | 9 +- pbs-api-types/src/ldap.rs | 5 +- pbs-api-types/src/lib.rs | 22 ++-- pbs-api-types/src/maintenance.rs | 4 +- pbs-api-types/src/metrics.rs | 2 +- pbs-api-types/src/openid.rs | 2 +- pbs-api-types/src/pathpatterns.rs | 2 +- pbs-api-types/src/percent_encoding.rs | 2 +- pbs-api-types/src/tape/changer.rs | 2 +- pbs-api-types/src/tape/drive.rs | 6 +- pbs-api-types/src/tape/media_location.rs | 2 +- pbs-api-types/src/tape/media_pool.rs | 2 +- pbs-api-types/src/tape/mod.rs | 4 +- pbs-api-types/src/traffic_control.rs | 2 +- pbs-api-types/src/user.rs | 4 +- pbs-api-types/src/version.rs | 2 +- proxmox-access-control/src/acl.rs | 29 +++-- proxmox-access-control/src/api/acl.rs | 6 +- proxmox-access-control/src/api/tokens.rs | 6 +- proxmox-access-control/src/init.rs | 6 +- proxmox-access-control/src/token_shadow.rs | 6 +- proxmox-access-control/src/types.rs | 6 +- proxmox-access-control/src/user.rs | 4 +- proxmox-acme-api/src/account_config.rs | 4 +- proxmox-acme-api/src/acme_plugin.rs | 2 +- proxmox-acme-api/src/certificate_helpers.rs | 6 +- proxmox-acme-api/src/lib.rs | 2 +- proxmox-acme-api/src/plugin_api_impl.rs | 4 +- proxmox-acme-api/src/plugin_config.rs | 4 +- proxmox-acme-api/src/types.rs | 2 +- proxmox-acme/src/account.rs | 2 +- proxmox-acme/src/async_client.rs | 4 +- proxmox-acme/src/authorization.rs | 2 +- proxmox-acme/src/eab.rs | 2 +- proxmox-acme/src/jws.rs | 2 +- proxmox-acme/src/key.rs | 2 +- proxmox-acme/src/order.rs | 2 +- proxmox-api-macro/src/api/enums.rs | 2 +- proxmox-api-macro/src/api/method.rs | 10 +- proxmox-api-macro/src/api/mod.rs | 2 +- proxmox-api-macro/src/api/structs.rs | 2 +- proxmox-api-macro/src/serde.rs | 2 +- proxmox-api-macro/src/util.rs | 2 +- proxmox-api-macro/tests/allof.rs | 2 +- proxmox-api-macro/tests/api1.rs | 2 +- proxmox-api-macro/tests/ext-schema.rs | 2 +- proxmox-api-macro/tests/options.rs | 2 +- proxmox-api-macro/tests/updater.rs | 2 +- proxmox-apt-api-types/src/lib.rs | 2 +- proxmox-apt/src/api.rs | 2 +- proxmox-apt/src/cache.rs | 4 +- proxmox-apt/src/cache_api.rs | 2 +- proxmox-apt/src/deb822/mod.rs | 2 +- proxmox-apt/src/deb822/packages_file.rs | 2 +- proxmox-apt/src/deb822/release_file.rs | 2 +- proxmox-apt/src/deb822/sources_file.rs | 2 +- proxmox-apt/src/repositories/file.rs | 2 +- .../src/repositories/file/list_parser.rs | 2 +- .../src/repositories/file/sources_parser.rs | 2 +- proxmox-apt/src/repositories/mod.rs | 4 +- proxmox-apt/src/repositories/release.rs | 2 +- proxmox-apt/src/repositories/repository.rs | 2 +- proxmox-apt/tests/repositories.rs | 6 +- proxmox-async/src/broadcast_future.rs | 4 +- proxmox-auth-api/examples/passwd.rs | 2 +- proxmox-auth-api/src/api/access.rs | 14 +-- proxmox-auth-api/src/api/mod.rs | 8 +- proxmox-auth-api/src/api/ticket.rs | 2 +- proxmox-auth-api/src/auth_key.rs | 2 +- proxmox-auth-api/src/pam_authenticator.rs | 4 +- .../src/password_authenticator.rs | 2 +- proxmox-auth-api/src/ticket.rs | 4 +- proxmox-auth-api/src/types.rs | 4 +- proxmox-base64/src/implementation.rs | 2 +- proxmox-client/src/client.rs | 2 +- proxmox-compression/src/zip.rs | 2 +- proxmox-compression/src/zstd.rs | 2 +- proxmox-compression/tests/zip.rs | 2 +- proxmox-config-digest/src/lib.rs | 4 +- proxmox-daemon/src/command_socket.rs | 2 +- proxmox-daemon/src/server.rs | 6 +- proxmox-daemon/src/state.rs | 6 +- proxmox-dns-api/src/api_types.rs | 4 +- proxmox-dns-api/src/resolv_conf.rs | 2 +- proxmox-docgen/src/lib.rs | 2 +- proxmox-http-error/src/lib.rs | 2 +- proxmox-http/src/client/connector.rs | 4 +- proxmox-http/src/client/simple.rs | 10 +- proxmox-http/src/proxy_config.rs | 2 +- proxmox-http/src/uri.rs | 2 +- proxmox-http/src/websocket/mod.rs | 4 +- proxmox-human-byte/src/lib.rs | 2 +- proxmox-io/src/lib.rs | 2 +- proxmox-lang/src/lib.rs | 4 +- proxmox-ldap/src/lib.rs | 2 +- proxmox-ldap/src/sync.rs | 8 +- proxmox-ldap/src/types.rs | 5 +- proxmox-ldap/tests/glauth.rs | 15 +-- proxmox-log/src/builder.rs | 8 +- proxmox-log/src/file_logger.rs | 2 +- proxmox-log/src/lib.rs | 2 +- proxmox-log/src/tasklog_layer.rs | 6 +- proxmox-metrics/src/influxdb/http.rs | 2 +- proxmox-metrics/src/influxdb/utils.rs | 2 +- proxmox-metrics/src/lib.rs | 2 +- proxmox-network-api/src/api_impl.rs | 4 +- proxmox-network-api/src/api_types.rs | 4 +- proxmox-network-api/src/config/helper.rs | 2 +- proxmox-network-api/src/config/mod.rs | 8 +- proxmox-network-api/src/config/parser.rs | 4 +- proxmox-network-types/src/ip_address.rs | 116 +++++++++++------- proxmox-network-types/src/mac_address.rs | 2 +- proxmox-node-status/src/api.rs | 2 +- proxmox-node-status/src/lib.rs | 2 +- proxmox-notify/src/api/gotify.rs | 46 +++---- proxmox-notify/src/api/matcher.rs | 22 ++-- proxmox-notify/src/api/sendmail.rs | 36 +++--- proxmox-notify/src/api/smtp.rs | 46 +++---- proxmox-notify/src/api/webhook.rs | 33 ++--- proxmox-notify/src/config.rs | 18 +-- proxmox-notify/src/context/mod.rs | 2 +- proxmox-notify/src/context/pbs.rs | 4 +- proxmox-notify/src/context/pve.rs | 4 +- proxmox-notify/src/context/test.rs | 2 +- proxmox-notify/src/endpoints/gotify.rs | 4 +- proxmox-notify/src/endpoints/sendmail.rs | 4 +- proxmox-notify/src/endpoints/smtp.rs | 8 +- proxmox-notify/src/endpoints/webhook.rs | 6 +- proxmox-notify/src/lib.rs | 4 +- proxmox-notify/src/matcher.rs | 4 +- proxmox-notify/src/renderer/mod.rs | 2 +- proxmox-oci/src/lib.rs | 4 +- proxmox-oci/src/oci_tar_image.rs | 2 +- proxmox-oci/tests/extract_replace.rs | 2 +- proxmox-oci/tests/extract_whiteouts.rs | 2 +- proxmox-openid/src/auth_state.rs | 6 +- proxmox-openid/src/lib.rs | 16 +-- proxmox-rate-limiter/src/rate_limiter.rs | 2 +- .../src/shared_rate_limiter.rs | 6 +- proxmox-resource-scheduling/src/pve_static.rs | 6 +- proxmox-resource-scheduling/src/topsis.rs | 2 +- proxmox-resource-scheduling/tests/topsis.rs | 2 +- .../examples/minimal-rest-server.rs | 6 +- proxmox-rest-server/src/api_config.rs | 10 +- proxmox-rest-server/src/compression.rs | 2 +- proxmox-rest-server/src/connection.rs | 4 +- proxmox-rest-server/src/environment.rs | 2 +- proxmox-rest-server/src/formatter.rs | 2 +- proxmox-rest-server/src/h2service.rs | 2 +- proxmox-rest-server/src/lib.rs | 2 +- proxmox-rest-server/src/rest.rs | 8 +- proxmox-rest-server/src/worker_task.rs | 6 +- proxmox-rest-server/tests/worker_task.rs | 4 +- proxmox-router/src/cli/command.rs | 6 +- proxmox-router/src/cli/completion.rs | 2 +- proxmox-router/src/cli/completion_helpers.rs | 2 +- proxmox-router/src/cli/format.rs | 6 +- proxmox-router/src/cli/mod.rs | 2 +- proxmox-router/src/cli/shellword.rs | 2 +- proxmox-router/src/cli/text_table.rs | 2 +- proxmox-router/src/error.rs | 2 +- proxmox-router/src/format.rs | 2 +- proxmox-router/src/permission.rs | 2 +- proxmox-router/src/router.rs | 74 ++++++----- proxmox-router/src/stream/parsing.rs | 4 +- proxmox-rrd/examples/prrd.rs | 10 +- proxmox-rrd/src/cache.rs | 8 +- proxmox-rrd/src/cache/journal.rs | 2 +- proxmox-rrd/src/cache/rrd_map.rs | 2 +- proxmox-rrd/src/rrd.rs | 4 +- proxmox-rrd/tests/file_format_test.rs | 2 +- proxmox-s3-client/src/api_types.rs | 2 +- proxmox-s3-client/src/aws_sign_v4.rs | 2 +- proxmox-s3-client/src/client.rs | 8 +- proxmox-s3-client/src/lib.rs | 2 +- proxmox-s3-client/src/object_key.rs | 2 +- proxmox-s3-client/src/response_reader.rs | 12 +- proxmox-s3-client/src/timestamps.rs | 2 +- proxmox-schema/src/de/mod.rs | 4 +- proxmox-schema/src/de/no_schema.rs | 2 +- proxmox-schema/src/format.rs | 2 +- proxmox-schema/src/property_string.rs | 22 ++-- proxmox-schema/src/schema.rs | 4 +- proxmox-schema/src/upid.rs | 6 +- proxmox-schema/tests/schema_verification.rs | 4 +- proxmox-section-config/src/lib.rs | 6 +- proxmox-section-config/src/typed.rs | 4 +- proxmox-sendmail/src/lib.rs | 4 +- proxmox-serde/src/json.rs | 2 +- proxmox-shared-cache/src/lib.rs | 2 +- proxmox-shared-memory/src/lib.rs | 2 +- proxmox-shared-memory/src/shared_mutex.rs | 4 +- .../tests/raw_shared_mutex.rs | 2 +- proxmox-simple-config/src/lib.rs | 2 +- proxmox-sortable-macro/src/lib.rs | 2 +- proxmox-subscription/src/check.rs | 6 +- proxmox-subscription/src/files.rs | 6 +- proxmox-subscription/src/lib.rs | 2 +- proxmox-subscription/src/sign.rs | 2 +- proxmox-subscription/src/subscription_info.rs | 10 +- proxmox-sys/src/command.rs | 2 +- proxmox-sys/src/crypt.rs | 2 +- proxmox-sys/src/fd.rs | 4 +- proxmox-sys/src/fs/acl.rs | 2 +- proxmox-sys/src/fs/dir.rs | 4 +- proxmox-sys/src/fs/file.rs | 4 +- proxmox-sys/src/fs/mod.rs | 2 +- proxmox-sys/src/fs/read_dir.rs | 2 +- proxmox-sys/src/linux/mod.rs | 2 +- proxmox-sys/src/linux/pid.rs | 2 +- proxmox-sys/src/linux/procfs/mod.rs | 2 +- proxmox-sys/src/linux/procfs/mountinfo.rs | 2 +- proxmox-sys/src/linux/tty.rs | 2 +- proxmox-sys/src/logrotate.rs | 6 +- proxmox-sys/src/macros.rs | 4 +- proxmox-sys/src/process_locker.rs | 2 +- proxmox-sys/src/systemd.rs | 2 +- proxmox-systemd/src/journal.rs | 2 +- proxmox-systemd/src/lib.rs | 2 +- proxmox-systemd/src/notify.rs | 2 +- proxmox-tfa/src/api/methods.rs | 2 +- proxmox-tfa/src/api/mod.rs | 2 +- proxmox-tfa/src/api/recovery.rs | 2 +- proxmox-tfa/src/api/webauthn.rs | 4 +- proxmox-tfa/src/totp.rs | 2 +- proxmox-tfa/src/u2f.rs | 6 +- proxmox-time-api/src/time_impl.rs | 2 +- proxmox-time/src/calendar_event.rs | 4 +- proxmox-time/src/daily_duration.rs | 6 +- proxmox-time/src/parse_helpers.rs | 2 +- proxmox-time/src/posix.rs | 2 +- proxmox-time/src/test.rs | 2 +- proxmox-time/src/time_span.rs | 2 +- proxmox-time/src/wasm.rs | 2 +- proxmox-time/src/week_days.rs | 2 +- proxmox-upgrade-checks/src/lib.rs | 2 +- proxmox-uuid/src/lib.rs | 4 +- proxmox-worker-task/src/lib.rs | 2 +- pve-api-types/src/types/mod.rs | 6 +- pve-api-types/src/types/verifiers.rs | 2 +- 244 files changed, 674 insertions(+), 626 deletions(-) diff --git a/pbs-api-types/src/acl.rs b/pbs-api-types/src/acl.rs index e7b87285..691af305 100644 --- a/pbs-api-types/src/acl.rs +++ b/pbs-api-types/src/acl.rs @@ -1,12 +1,12 @@ use std::str::FromStr; use const_format::concatcp; -use serde::de::{value, IntoDeserializer}; +use serde::de::{IntoDeserializer, value}; use serde::{Deserialize, Serialize}; use proxmox_lang::constnamedbitmap; use proxmox_schema::{ - api, const_regex, ApiStringFormat, BooleanSchema, EnumEntry, Schema, StringSchema, + ApiStringFormat, BooleanSchema, EnumEntry, Schema, StringSchema, api, const_regex, }; use crate::PROXMOX_SAFE_ID_REGEX_STR; diff --git a/pbs-api-types/src/ad.rs b/pbs-api-types/src/ad.rs index 80a7a035..35faf932 100644 --- a/pbs-api-types/src/ad.rs +++ b/pbs-api-types/src/ad.rs @@ -1,9 +1,9 @@ use serde::{Deserialize, Serialize}; -use proxmox_schema::{api, Updater}; +use proxmox_schema::{Updater, api}; use super::{ - LdapMode, LDAP_DOMAIN_SCHEMA, REALM_ID_SCHEMA, SINGLE_LINE_COMMENT_SCHEMA, + LDAP_DOMAIN_SCHEMA, LdapMode, REALM_ID_SCHEMA, SINGLE_LINE_COMMENT_SCHEMA, SYNC_ATTRIBUTES_SCHEMA, SYNC_DEFAULTS_STRING_SCHEMA, USER_CLASSES_SCHEMA, }; diff --git a/pbs-api-types/src/crypto.rs b/pbs-api-types/src/crypto.rs index 536c53b4..39b0345b 100644 --- a/pbs-api-types/src/crypto.rs +++ b/pbs-api-types/src/crypto.rs @@ -75,7 +75,7 @@ fn as_fingerprint(bytes: &[u8]) -> String { pub mod bytes_as_fingerprint { use std::fmt; - use serde::{de, Deserializer, Serializer}; + use serde::{Deserializer, Serializer, de}; pub fn serialize(bytes: &[u8; 32], serializer: S) -> Result where diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index b4e7ccf5..3bc6c79b 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::LazyLock; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use const_format::concatcp; use serde::{Deserialize, Serialize}; @@ -13,17 +13,17 @@ use proxmox_fixed_string::FixedString; use proxmox_human_byte::HumanByte; use proxmox_schema::{ - api, const_regex, ApiStringFormat, ApiType, ArraySchema, EnumEntry, IntegerSchema, ReturnType, - Schema, StringSchema, Updater, UpdaterType, + ApiStringFormat, ApiType, ArraySchema, EnumEntry, IntegerSchema, ReturnType, Schema, + StringSchema, Updater, UpdaterType, api, const_regex, }; use crate::{ - Authid, CryptMode, Fingerprint, GroupFilter, MaintenanceMode, MaintenanceType, Userid, - BACKUP_ID_RE, BACKUP_NS_RE, BACKUP_TIME_RE, BACKUP_TYPE_RE, DATASTORE_NOTIFY_STRING_SCHEMA, - GC_SCHEDULE_SCHEMA, GROUP_OR_SNAPSHOT_PATH_REGEX_STR, PROXMOX_SAFE_ID_FORMAT, - PROXMOX_SAFE_ID_REGEX_STR, PRUNE_SCHEDULE_SCHEMA, SHA256_HEX_REGEX, SINGLE_LINE_COMMENT_SCHEMA, - SNAPSHOT_PATH_REGEX_STR, UPID, VERIFY_JOB_READ_THREADS_SCHEMA, - VERIFY_JOB_VERIFY_THREADS_SCHEMA, + Authid, BACKUP_ID_RE, BACKUP_NS_RE, BACKUP_TIME_RE, BACKUP_TYPE_RE, CryptMode, + DATASTORE_NOTIFY_STRING_SCHEMA, Fingerprint, GC_SCHEDULE_SCHEMA, + GROUP_OR_SNAPSHOT_PATH_REGEX_STR, GroupFilter, MaintenanceMode, MaintenanceType, + PROXMOX_SAFE_ID_FORMAT, PROXMOX_SAFE_ID_REGEX_STR, PRUNE_SCHEDULE_SCHEMA, SHA256_HEX_REGEX, + SINGLE_LINE_COMMENT_SCHEMA, SNAPSHOT_PATH_REGEX_STR, UPID, Userid, + VERIFY_JOB_READ_THREADS_SCHEMA, VERIFY_JOB_VERIFY_THREADS_SCHEMA, }; const_regex! { diff --git a/pbs-api-types/src/jobs.rs b/pbs-api-types/src/jobs.rs index b188cdc6..a7b37e5c 100644 --- a/pbs-api-types/src/jobs.rs +++ b/pbs-api-types/src/jobs.rs @@ -11,10 +11,11 @@ use proxmox_fixed_string::FixedString; use proxmox_schema::*; use crate::{ - Authid, BackupNamespace, BackupType, NotificationMode, RateLimitConfig, Userid, - BACKUP_GROUP_SCHEMA, BACKUP_NAMESPACE_SCHEMA, BACKUP_NS_RE, DATASTORE_SCHEMA, - DRIVE_NAME_SCHEMA, MEDIA_POOL_NAME_SCHEMA, NS_MAX_DEPTH_REDUCED_SCHEMA, PROXMOX_SAFE_ID_FORMAT, - PROXMOX_SAFE_ID_REGEX_STR, REMOTE_ID_SCHEMA, SINGLE_LINE_COMMENT_SCHEMA, + Authid, BACKUP_GROUP_SCHEMA, BACKUP_NAMESPACE_SCHEMA, BACKUP_NS_RE, BackupNamespace, + BackupType, DATASTORE_SCHEMA, DRIVE_NAME_SCHEMA, MEDIA_POOL_NAME_SCHEMA, + NS_MAX_DEPTH_REDUCED_SCHEMA, NotificationMode, PROXMOX_SAFE_ID_FORMAT, + PROXMOX_SAFE_ID_REGEX_STR, REMOTE_ID_SCHEMA, RateLimitConfig, SINGLE_LINE_COMMENT_SCHEMA, + Userid, }; const_regex! { diff --git a/pbs-api-types/src/ldap.rs b/pbs-api-types/src/ldap.rs index ff380ffe..7320d51e 100644 --- a/pbs-api-types/src/ldap.rs +++ b/pbs-api-types/src/ldap.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "enum-fallback")] use proxmox_fixed_string::FixedString; -use proxmox_schema::{api, ApiStringFormat, ApiType, ArraySchema, Schema, StringSchema, Updater}; +use proxmox_schema::{ApiStringFormat, ApiType, ArraySchema, Schema, StringSchema, Updater, api}; use super::{REALM_ID_SCHEMA, SINGLE_LINE_COMMENT_SCHEMA}; @@ -164,8 +164,7 @@ pub const SYNC_DEFAULTS_STRING_SCHEMA: Schema = StringSchema::new("sync defaults )) .schema(); -const REMOVE_VANISHED_DESCRIPTION: &str = - "A semicolon-separated list of things to remove when they or the user \ +const REMOVE_VANISHED_DESCRIPTION: &str = "A semicolon-separated list of things to remove when they or the user \ vanishes during user synchronization. The following values are possible: ``entry`` removes the \ user when not returned from the sync; ``properties`` removes any \ properties on existing user that do not appear in the source. \ diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs index 54547291..3b386efc 100644 --- a/pbs-api-types/src/lib.rs +++ b/pbs-api-types/src/lib.rs @@ -6,8 +6,8 @@ use serde::{Deserialize, Serialize}; pub mod percent_encoding; use proxmox_schema::{ - api, const_regex, ApiStringFormat, ApiType, ArraySchema, ReturnType, Schema, StringSchema, - Updater, + ApiStringFormat, ApiType, ArraySchema, ReturnType, Schema, StringSchema, Updater, api, + const_regex, }; use proxmox_time::parse_daily_duration; @@ -25,7 +25,7 @@ pub use proxmox_schema::api_types::{ pub use proxmox_schema::api_types::{DNS_ALIAS_REGEX, DNS_NAME_OR_IP_REGEX, DNS_NAME_REGEX}; pub use proxmox_schema::api_types::{FINGERPRINT_SHA256_REGEX, SHA256_HEX_REGEX}; pub use proxmox_schema::api_types::{ - GENERIC_URI_REGEX, HOSTNAME_REGEX, HOST_PORT_REGEX, HTTP_URL_REGEX, + GENERIC_URI_REGEX, HOST_PORT_REGEX, HOSTNAME_REGEX, HTTP_URL_REGEX, }; pub use proxmox_schema::api_types::{MULTI_LINE_COMMENT_REGEX, SINGLE_LINE_COMMENT_REGEX}; pub use proxmox_schema::api_types::{PASSWORD_REGEX, SYSTEMD_DATETIME_REGEX, UUID_REGEX}; @@ -33,13 +33,13 @@ pub use proxmox_schema::api_types::{PASSWORD_REGEX, SYSTEMD_DATETIME_REGEX, UUID pub use proxmox_schema::api_types::{CIDR_FORMAT, CIDR_REGEX}; pub use proxmox_schema::api_types::{CIDR_V4_FORMAT, CIDR_V4_REGEX}; pub use proxmox_schema::api_types::{CIDR_V6_FORMAT, CIDR_V6_REGEX}; -pub use proxmox_schema::api_types::{IPRE_STR, IP_FORMAT, IP_REGEX}; -pub use proxmox_schema::api_types::{IPV4RE_STR, IP_V4_FORMAT, IP_V4_REGEX}; -pub use proxmox_schema::api_types::{IPV6RE_STR, IP_V6_FORMAT, IP_V6_REGEX}; +pub use proxmox_schema::api_types::{IP_FORMAT, IP_REGEX, IPRE_STR}; +pub use proxmox_schema::api_types::{IP_V4_FORMAT, IP_V4_REGEX, IPV4RE_STR}; +pub use proxmox_schema::api_types::{IP_V6_FORMAT, IP_V6_REGEX, IPV6RE_STR}; pub use proxmox_schema::api_types::COMMENT_SCHEMA as SINGLE_LINE_COMMENT_SCHEMA; -pub use proxmox_schema::api_types::HOSTNAME_SCHEMA; pub use proxmox_schema::api_types::HOST_PORT_SCHEMA; +pub use proxmox_schema::api_types::HOSTNAME_SCHEMA; pub use proxmox_schema::api_types::HTTP_URL_SCHEMA; pub use proxmox_schema::api_types::MULTI_LINE_COMMENT_SCHEMA; pub use proxmox_schema::api_types::NODE_SCHEMA; @@ -114,12 +114,12 @@ pub use node::*; pub use proxmox_auth_api::types as userid; pub use proxmox_auth_api::types::{Authid, Userid}; -pub use proxmox_auth_api::types::{Realm, RealmRef}; -pub use proxmox_auth_api::types::{Tokenname, TokennameRef}; -pub use proxmox_auth_api::types::{Username, UsernameRef}; pub use proxmox_auth_api::types::{ PROXMOX_GROUP_ID_SCHEMA, PROXMOX_TOKEN_ID_SCHEMA, PROXMOX_TOKEN_NAME_SCHEMA, }; +pub use proxmox_auth_api::types::{Realm, RealmRef}; +pub use proxmox_auth_api::types::{Tokenname, TokennameRef}; +pub use proxmox_auth_api::types::{Username, UsernameRef}; #[macro_use] mod user; @@ -128,7 +128,7 @@ pub use user::*; pub use proxmox_schema::upid::*; mod crypto; -pub use crypto::{bytes_as_fingerprint, CryptMode, Fingerprint}; +pub use crypto::{CryptMode, Fingerprint, bytes_as_fingerprint}; pub mod file_restore; diff --git a/pbs-api-types/src/maintenance.rs b/pbs-api-types/src/maintenance.rs index baf4e29a..d2c71df3 100644 --- a/pbs-api-types/src/maintenance.rs +++ b/pbs-api-types/src/maintenance.rs @@ -1,11 +1,11 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use serde::{Deserialize, Serialize}; use std::borrow::Cow; #[cfg(feature = "enum-fallback")] use proxmox_fixed_string::FixedString; -use proxmox_schema::{api, const_regex, ApiStringFormat, Schema, StringSchema}; +use proxmox_schema::{ApiStringFormat, Schema, StringSchema, api, const_regex}; const_regex! { pub MAINTENANCE_MESSAGE_REGEX = r"^[[:^cntrl:]]*$"; diff --git a/pbs-api-types/src/metrics.rs b/pbs-api-types/src/metrics.rs index 5ce2c9fc..1e59f92e 100644 --- a/pbs-api-types/src/metrics.rs +++ b/pbs-api-types/src/metrics.rs @@ -7,7 +7,7 @@ use crate::{ #[cfg(feature = "enum-fallback")] use proxmox_fixed_string::FixedString; -use proxmox_schema::{api, Schema, StringSchema, Updater}; +use proxmox_schema::{Schema, StringSchema, Updater, api}; pub const METRIC_SERVER_ID_SCHEMA: Schema = StringSchema::new("Metrics Server ID.") .format(&PROXMOX_SAFE_ID_FORMAT) diff --git a/pbs-api-types/src/openid.rs b/pbs-api-types/src/openid.rs index 0333272b..cdb895ef 100644 --- a/pbs-api-types/src/openid.rs +++ b/pbs-api-types/src/openid.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -use proxmox_schema::{api, ApiStringFormat, ArraySchema, Schema, StringSchema, Updater}; +use proxmox_schema::{ApiStringFormat, ArraySchema, Schema, StringSchema, Updater, api}; use super::{ GENERIC_URI_REGEX, PROXMOX_SAFE_ID_FORMAT, PROXMOX_SAFE_ID_REGEX, REALM_ID_SCHEMA, diff --git a/pbs-api-types/src/pathpatterns.rs b/pbs-api-types/src/pathpatterns.rs index b9675b96..6de62bfd 100644 --- a/pbs-api-types/src/pathpatterns.rs +++ b/pbs-api-types/src/pathpatterns.rs @@ -1,4 +1,4 @@ -use proxmox_schema::{const_regex, ApiStringFormat, ApiType, Schema, StringSchema}; +use proxmox_schema::{ApiStringFormat, ApiType, Schema, StringSchema, const_regex}; use serde::{Deserialize, Serialize}; diff --git a/pbs-api-types/src/percent_encoding.rs b/pbs-api-types/src/percent_encoding.rs index afe011e2..6d6dcf80 100644 --- a/pbs-api-types/src/percent_encoding.rs +++ b/pbs-api-types/src/percent_encoding.rs @@ -1,4 +1,4 @@ -use percent_encoding::{utf8_percent_encode, AsciiSet}; +use percent_encoding::{AsciiSet, utf8_percent_encode}; /// This used to be: `SIMPLE_ENCODE_SET` plus space, `"`, `#`, `<`, `>`, backtick, `?`, `{`, `}` pub const DEFAULT_ENCODE_SET: &AsciiSet = &percent_encoding::CONTROLS // 0..1f and 7e diff --git a/pbs-api-types/src/tape/changer.rs b/pbs-api-types/src/tape/changer.rs index 1f818844..90202b5b 100644 --- a/pbs-api-types/src/tape/changer.rs +++ b/pbs-api-types/src/tape/changer.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use proxmox_fixed_string::FixedString; use proxmox_schema::{ - api, ApiStringFormat, ArraySchema, IntegerSchema, Schema, StringSchema, Updater, + ApiStringFormat, ArraySchema, IntegerSchema, Schema, StringSchema, Updater, api, }; use crate::{OptionalDeviceIdentification, PROXMOX_SAFE_ID_FORMAT}; diff --git a/pbs-api-types/src/tape/drive.rs b/pbs-api-types/src/tape/drive.rs index 720ba5e4..9f7599ba 100644 --- a/pbs-api-types/src/tape/drive.rs +++ b/pbs-api-types/src/tape/drive.rs @@ -1,13 +1,13 @@ //! Types for tape drive API -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use serde::{Deserialize, Serialize}; #[cfg(feature = "enum-fallback")] use proxmox_fixed_string::FixedString; -use proxmox_schema::{api, IntegerSchema, Schema, StringSchema, Updater}; +use proxmox_schema::{IntegerSchema, Schema, StringSchema, Updater, api}; -use crate::{OptionalDeviceIdentification, CHANGER_NAME_SCHEMA, PROXMOX_SAFE_ID_FORMAT}; +use crate::{CHANGER_NAME_SCHEMA, OptionalDeviceIdentification, PROXMOX_SAFE_ID_FORMAT}; pub const DRIVE_NAME_SCHEMA: Schema = StringSchema::new("Drive Identifier.") .format(&PROXMOX_SAFE_ID_FORMAT) diff --git a/pbs-api-types/src/tape/media_location.rs b/pbs-api-types/src/tape/media_location.rs index 62042385..54634cf7 100644 --- a/pbs-api-types/src/tape/media_location.rs +++ b/pbs-api-types/src/tape/media_location.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use proxmox_schema::{ApiStringFormat, Schema, StringSchema}; diff --git a/pbs-api-types/src/tape/media_pool.rs b/pbs-api-types/src/tape/media_pool.rs index c3eacec7..46d528f1 100644 --- a/pbs-api-types/src/tape/media_pool.rs +++ b/pbs-api-types/src/tape/media_pool.rs @@ -9,7 +9,7 @@ use std::str::FromStr; use anyhow::Error; use serde::{Deserialize, Serialize}; -use proxmox_schema::{api, ApiStringFormat, Schema, StringSchema, Updater}; +use proxmox_schema::{ApiStringFormat, Schema, StringSchema, Updater, api}; use proxmox_time::{CalendarEvent, TimeSpan}; diff --git a/pbs-api-types/src/tape/mod.rs b/pbs-api-types/src/tape/mod.rs index 6a9d56bc..0034d65c 100644 --- a/pbs-api-types/src/tape/mod.rs +++ b/pbs-api-types/src/tape/mod.rs @@ -25,11 +25,11 @@ pub use media::*; use const_format::concatcp; use serde::{Deserialize, Serialize}; -use proxmox_schema::{api, const_regex, ApiStringFormat, Schema, StringSchema}; +use proxmox_schema::{ApiStringFormat, Schema, StringSchema, api, const_regex}; use proxmox_uuid::Uuid; use crate::{ - BackupType, BACKUP_ID_SCHEMA, BACKUP_NS_PATH_RE, FINGERPRINT_SHA256_FORMAT, + BACKUP_ID_SCHEMA, BACKUP_NS_PATH_RE, BackupType, FINGERPRINT_SHA256_FORMAT, PROXMOX_SAFE_ID_REGEX_STR, SNAPSHOT_PATH_REGEX_STR, }; diff --git a/pbs-api-types/src/traffic_control.rs b/pbs-api-types/src/traffic_control.rs index 174f53a2..d9ba5e54 100644 --- a/pbs-api-types/src/traffic_control.rs +++ b/pbs-api-types/src/traffic_control.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use proxmox_human_byte::HumanByte; -use proxmox_schema::{api, ApiType, Schema, StringSchema, Updater}; +use proxmox_schema::{ApiType, Schema, StringSchema, Updater, api}; use proxmox_schema::api_types::CIDR_SCHEMA; diff --git a/pbs-api-types/src/user.rs b/pbs-api-types/src/user.rs index 21c434f1..a5368916 100644 --- a/pbs-api-types/src/user.rs +++ b/pbs-api-types/src/user.rs @@ -1,8 +1,8 @@ use serde::{Deserialize, Serialize}; -use proxmox_schema::{api, BooleanSchema, IntegerSchema, Schema, StringSchema, Updater}; +use proxmox_schema::{BooleanSchema, IntegerSchema, Schema, StringSchema, Updater, api}; -use super::userid::{Authid, Userid, PROXMOX_TOKEN_ID_SCHEMA}; +use super::userid::{Authid, PROXMOX_TOKEN_ID_SCHEMA, Userid}; use super::{SINGLE_LINE_COMMENT_FORMAT, SINGLE_LINE_COMMENT_SCHEMA}; pub const ENABLE_USER_SCHEMA: Schema = BooleanSchema::new( diff --git a/pbs-api-types/src/version.rs b/pbs-api-types/src/version.rs index 09e725eb..aeaa38b9 100644 --- a/pbs-api-types/src/version.rs +++ b/pbs-api-types/src/version.rs @@ -2,7 +2,7 @@ use std::cmp::Ordering; use std::convert::TryFrom; -use anyhow::{format_err, Context}; +use anyhow::{Context, format_err}; use proxmox_schema::api; diff --git a/proxmox-access-control/src/acl.rs b/proxmox-access-control/src/acl.rs index 38cb7edf..ecc843e6 100644 --- a/proxmox-access-control/src/acl.rs +++ b/proxmox-access-control/src/acl.rs @@ -6,7 +6,7 @@ use std::io::Write; #[cfg(feature = "impl")] use std::path::Path; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use proxmox_auth_api::types::{Authid, Userid}; #[cfg(feature = "impl")] @@ -654,10 +654,10 @@ pub use impl_feature::{cached_config, config, lock_config, save_config}; mod impl_feature { use std::sync::{Arc, OnceLock, RwLock}; - use anyhow::{bail, Error}; + use anyhow::{Error, bail}; use proxmox_config_digest::ConfigDigest; - use proxmox_product_config::{open_api_lockfile, replace_privileged_config, ApiLockGuard}; + use proxmox_product_config::{ApiLockGuard, open_api_lockfile, replace_privileged_config}; use crate::acl::AclTree; use crate::init::access_conf; @@ -763,7 +763,7 @@ fn privs_to_priv_names(privs: u64) -> Vec<&'static str> { mod test { use std::{collections::HashMap, sync::OnceLock}; - use crate::init::{init_access_config, AccessControlConfig}; + use crate::init::{AccessControlConfig, init_access_config}; use super::AclTree; use anyhow::Error; @@ -986,9 +986,10 @@ mod test { ); // user2 has no privileges under "/store/store2/store3" --> return empty - assert!(tree - .get_child_paths(&user2, &["store", "store2", "store3"],)? - .is_empty()); + assert!( + tree.get_child_paths(&user2, &["store", "store2", "store3"],)? + .is_empty() + ); // user2 has DatastoreReader privileges under "/store/store2/store31" --> return paths let paths = tree.get_child_paths(&user2, &["store/store2/store31"])?; @@ -997,15 +998,17 @@ mod test { ); // user2 has no privileges under "/store/store2/foo/bar/baz" - assert!(tree - .get_child_paths(&user2, &["store", "store2", "foo/bar/baz"])? - .is_empty()); + assert!( + tree.get_child_paths(&user2, &["store", "store2", "foo/bar/baz"])? + .is_empty() + ); // user2 has DatastoreReader privileges on "/store/store2/store31/store4/store6", but not // on any child paths --> return empty - assert!(tree - .get_child_paths(&user2, &["store/store2/store31/store4/store6"],)? - .is_empty()); + assert!( + tree.get_child_paths(&user2, &["store/store2/store31/store4/store6"],)? + .is_empty() + ); Ok(()) } diff --git a/proxmox-access-control/src/api/acl.rs b/proxmox-access-control/src/api/acl.rs index c8f046d2..1c084e6e 100644 --- a/proxmox-access-control/src/api/acl.rs +++ b/proxmox-access-control/src/api/acl.rs @@ -1,14 +1,14 @@ -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use proxmox_auth_api::types::{Authid, PROXMOX_GROUP_ID_SCHEMA}; use proxmox_config_digest::{ConfigDigest, PROXMOX_CONFIG_DIGEST_SCHEMA}; use proxmox_router::{Permission, Router, RpcEnvironment}; use proxmox_schema::api; +use crate::CachedUserInfo; use crate::acl::AclTreeNode; use crate::init::access_conf; -use crate::types::{AclListItem, AclUgidType, RoleInfo, ACL_PATH_SCHEMA, ACL_PROPAGATE_SCHEMA}; -use crate::CachedUserInfo; +use crate::types::{ACL_PATH_SCHEMA, ACL_PROPAGATE_SCHEMA, AclListItem, AclUgidType, RoleInfo}; #[api( input: { diff --git a/proxmox-access-control/src/api/tokens.rs b/proxmox-access-control/src/api/tokens.rs index 0ed710c6..f7417934 100644 --- a/proxmox-access-control/src/api/tokens.rs +++ b/proxmox-access-control/src/api/tokens.rs @@ -1,6 +1,6 @@ //! User Management -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use proxmox_config_digest::ConfigDigest; use proxmox_schema::api_types::COMMENT_SCHEMA; @@ -11,8 +11,8 @@ use proxmox_schema::api; use crate::acl; use crate::token_shadow::{self}; use crate::types::{ - ApiToken, ApiTokenSecret, DeletableTokenProperty, TokenApiEntry, ENABLE_USER_SCHEMA, - EXPIRE_USER_SCHEMA, REGENERATE_TOKEN_SCHEMA, + ApiToken, ApiTokenSecret, DeletableTokenProperty, ENABLE_USER_SCHEMA, EXPIRE_USER_SCHEMA, + REGENERATE_TOKEN_SCHEMA, TokenApiEntry, }; #[api( diff --git a/proxmox-access-control/src/init.rs b/proxmox-access-control/src/init.rs index e64398e8..52c3393a 100644 --- a/proxmox-access-control/src/init.rs +++ b/proxmox-access-control/src/init.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::sync::OnceLock; -use anyhow::{format_err, Error}; +use anyhow::{Error, format_err}; use proxmox_auth_api::types::{Authid, Userid}; use proxmox_section_config::SectionConfigData; @@ -123,9 +123,9 @@ pub(crate) mod impl_feature { use std::path::{Path, PathBuf}; use std::sync::OnceLock; - use anyhow::{format_err, Error}; + use anyhow::{Error, format_err}; - use crate::init::{init_access_config, AccessControlConfig}; + use crate::init::{AccessControlConfig, init_access_config}; static ACCESS_CONF_DIR: OnceLock = OnceLock::new(); diff --git a/proxmox-access-control/src/token_shadow.rs b/proxmox-access-control/src/token_shadow.rs index c586d834..68b88a20 100644 --- a/proxmox-access-control/src/token_shadow.rs +++ b/proxmox-access-control/src/token_shadow.rs @@ -1,10 +1,10 @@ use std::collections::HashMap; -use anyhow::{bail, format_err, Error}; -use serde_json::{from_value, Value}; +use anyhow::{Error, bail, format_err}; +use serde_json::{Value, from_value}; use proxmox_auth_api::types::Authid; -use proxmox_product_config::{open_api_lockfile, replace_config, ApiLockGuard}; +use proxmox_product_config::{ApiLockGuard, open_api_lockfile, replace_config}; use crate::init::impl_feature::{token_shadow, token_shadow_lock}; diff --git a/proxmox-access-control/src/types.rs b/proxmox-access-control/src/types.rs index 78eafb4c..875b3d93 100644 --- a/proxmox-access-control/src/types.rs +++ b/proxmox-access-control/src/types.rs @@ -2,11 +2,11 @@ use serde::{Deserialize, Serialize}; use const_format::concatcp; -use proxmox_auth_api::types::{Authid, Tokenname, Userid, PROXMOX_TOKEN_ID_SCHEMA}; +use proxmox_auth_api::types::{Authid, PROXMOX_TOKEN_ID_SCHEMA, Tokenname, Userid}; use proxmox_schema::{ - api, + ApiStringFormat, BooleanSchema, IntegerSchema, Schema, StringSchema, Updater, api, api_types::{COMMENT_SCHEMA, SAFE_ID_REGEX_STR, SINGLE_LINE_COMMENT_FORMAT}, - const_regex, ApiStringFormat, BooleanSchema, IntegerSchema, Schema, StringSchema, Updater, + const_regex, }; pub const ENABLE_USER_SCHEMA: Schema = BooleanSchema::new( diff --git a/proxmox-access-control/src/user.rs b/proxmox-access-control/src/user.rs index a4b59edc..6bb58a49 100644 --- a/proxmox-access-control/src/user.rs +++ b/proxmox-access-control/src/user.rs @@ -1,11 +1,11 @@ use std::collections::HashMap; use std::sync::{Arc, OnceLock, RwLock}; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use proxmox_auth_api::types::Authid; use proxmox_config_digest::ConfigDigest; -use proxmox_product_config::{open_api_lockfile, replace_privileged_config, ApiLockGuard}; +use proxmox_product_config::{ApiLockGuard, open_api_lockfile, replace_privileged_config}; use proxmox_schema::*; use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin}; diff --git a/proxmox-acme-api/src/account_config.rs b/proxmox-acme-api/src/account_config.rs index a9cda1b6..ce128c45 100644 --- a/proxmox-acme-api/src/account_config.rs +++ b/proxmox-acme-api/src/account_config.rs @@ -5,7 +5,7 @@ use std::ops::ControlFlow; use std::os::unix::fs::OpenOptionsExt; use std::path::{Path, PathBuf}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use serde::{Deserialize, Serialize}; use proxmox_product_config::replace_secret_config; @@ -13,9 +13,9 @@ use proxmox_sys::error::SysError; use proxmox_schema::api_types::SAFE_ID_REGEX; +use proxmox_acme::Account; use proxmox_acme::async_client::AcmeClient; use proxmox_acme::types::AccountData as AcmeAccountData; -use proxmox_acme::Account; use crate::acme_account_dir; use crate::types::AcmeAccountName; diff --git a/proxmox-acme-api/src/acme_plugin.rs b/proxmox-acme-api/src/acme_plugin.rs index c20b2618..c81180f7 100644 --- a/proxmox-acme-api/src/acme_plugin.rs +++ b/proxmox-acme-api/src/acme_plugin.rs @@ -6,7 +6,7 @@ use std::process::Stdio; use std::sync::Arc; use std::time::Duration; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use futures::TryFutureExt; use http::{Request, Response}; use http_body_util::Full; diff --git a/proxmox-acme-api/src/certificate_helpers.rs b/proxmox-acme-api/src/certificate_helpers.rs index a4fe153a..3921b18e 100644 --- a/proxmox-acme-api/src/certificate_helpers.rs +++ b/proxmox-acme-api/src/certificate_helpers.rs @@ -4,17 +4,17 @@ use std::time::Duration; use foreign_types::ForeignTypeRef; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use openssl::pkey::{PKey, Private}; use openssl::rsa::Rsa; -use openssl::x509::{X509Builder, X509}; +use openssl::x509::{X509, X509Builder}; use proxmox_acme::async_client::AcmeClient; use proxmox_log::{info, warn}; use proxmox_rest_server::WorkerTask; -use crate::types::{AcmeConfig, AcmeDomain}; use crate::CertificateInfo; +use crate::types::{AcmeConfig, AcmeDomain}; pub async fn revoke_certificate(acme_config: &AcmeConfig, certificate: &[u8]) -> Result<(), Error> { let mut acme = super::account_config::load_account_config(&acme_config.account) diff --git a/proxmox-acme-api/src/lib.rs b/proxmox-acme-api/src/lib.rs index 623e9e23..196269b6 100644 --- a/proxmox-acme-api/src/lib.rs +++ b/proxmox-acme-api/src/lib.rs @@ -17,7 +17,7 @@ pub use config::{DEFAULT_ACME_DIRECTORY_ENTRY, KNOWN_ACME_DIRECTORIES}; #[cfg(feature = "impl")] mod challenge_schemas; #[cfg(feature = "impl")] -pub use challenge_schemas::{get_cached_challenge_schemas, ChallengeSchemaWrapper}; +pub use challenge_schemas::{ChallengeSchemaWrapper, get_cached_challenge_schemas}; #[cfg(feature = "impl")] mod account_config; diff --git a/proxmox-acme-api/src/plugin_api_impl.rs b/proxmox-acme-api/src/plugin_api_impl.rs index d0548e4b..5f5c158a 100644 --- a/proxmox-acme-api/src/plugin_api_impl.rs +++ b/proxmox-acme-api/src/plugin_api_impl.rs @@ -1,6 +1,6 @@ //! ACME plugin configuration API implementation -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use serde::Deserialize; use serde_json::Value; @@ -12,7 +12,7 @@ use crate::types::{ DeletablePluginProperty, DnsPlugin, DnsPluginCore, DnsPluginCoreUpdater, PluginConfig, }; -use proxmox_router::{http_bail, RpcEnvironment}; +use proxmox_router::{RpcEnvironment, http_bail}; pub fn list_plugins(rpcenv: &mut dyn RpcEnvironment) -> Result, Error> { let (plugins, digest) = super::plugin_config::plugin_config()?; diff --git a/proxmox-acme-api/src/plugin_config.rs b/proxmox-acme-api/src/plugin_config.rs index 3295e15d..56821723 100644 --- a/proxmox-acme-api/src/plugin_config.rs +++ b/proxmox-acme-api/src/plugin_config.rs @@ -6,11 +6,11 @@ use anyhow::Error; use serde_json::Value; use proxmox_config_digest::ConfigDigest; -use proxmox_product_config::{open_api_lockfile, replace_secret_config, ApiLockGuard}; +use proxmox_product_config::{ApiLockGuard, open_api_lockfile, replace_secret_config}; use proxmox_schema::{ApiType, Schema}; use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin}; -use crate::types::{DnsPlugin, StandalonePlugin, PLUGIN_ID_SCHEMA}; +use crate::types::{DnsPlugin, PLUGIN_ID_SCHEMA, StandalonePlugin}; static CONFIG: LazyLock = LazyLock::new(init); diff --git a/proxmox-acme-api/src/types.rs b/proxmox-acme-api/src/types.rs index d46497ca..934e6ece 100644 --- a/proxmox-acme-api/src/types.rs +++ b/proxmox-acme-api/src/types.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use proxmox_schema::api_types::{DNS_ALIAS_FORMAT, DNS_NAME_FORMAT, SAFE_ID_FORMAT}; -use proxmox_schema::{api, ApiStringFormat, ApiType, Schema, StringSchema, Updater}; +use proxmox_schema::{ApiStringFormat, ApiType, Schema, StringSchema, Updater, api}; use proxmox_acme::types::AccountData as AcmeAccountData; diff --git a/proxmox-acme/src/account.rs b/proxmox-acme/src/account.rs index f763c1e9..fa373a10 100644 --- a/proxmox-acme/src/account.rs +++ b/proxmox-acme/src/account.rs @@ -8,6 +8,7 @@ use openssl::pkey::{PKey, Private}; use serde::{Deserialize, Serialize}; use serde_json::Value; +use crate::Error; use crate::authorization::{Authorization, GetAuthorization}; use crate::b64u; use crate::directory::Directory; @@ -16,7 +17,6 @@ use crate::key::{Jwk, PublicKey}; use crate::order::{NewOrder, Order, OrderData}; use crate::request::Request; use crate::types::{AccountData, AccountStatus, ExternalAccountBinding}; -use crate::Error; /// An ACME Account. /// diff --git a/proxmox-acme/src/async_client.rs b/proxmox-acme/src/async_client.rs index dc755fb9..9e09d05b 100644 --- a/proxmox-acme/src/async_client.rs +++ b/proxmox-acme/src/async_client.rs @@ -6,11 +6,11 @@ use http_body_util::BodyExt; use hyper::Request; use serde::{Deserialize, Serialize}; -use proxmox_http::{client::Client, Body}; +use proxmox_http::{Body, client::Client}; +use crate::Request as AcmeRequest; use crate::account::AccountCreator; use crate::order::{Order, OrderData}; -use crate::Request as AcmeRequest; use crate::{Account, Authorization, Challenge, Directory, Error, ErrorResponse}; /// A non-blocking Acme client using tokio/hyper. diff --git a/proxmox-acme/src/authorization.rs b/proxmox-acme/src/authorization.rs index 28bc1b4b..a4a1f019 100644 --- a/proxmox-acme/src/authorization.rs +++ b/proxmox-acme/src/authorization.rs @@ -5,9 +5,9 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use serde_json::Value; +use crate::Error; use crate::order::Identifier; use crate::request::Request; -use crate::Error; /// Status of an [`Authorization`]. #[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize)] diff --git a/proxmox-acme/src/eab.rs b/proxmox-acme/src/eab.rs index 3e0d2816..7052a54f 100644 --- a/proxmox-acme/src/eab.rs +++ b/proxmox-acme/src/eab.rs @@ -6,7 +6,7 @@ use serde::Serialize; use crate::key::Jwk; use crate::types::ExternalAccountBinding; -use crate::{b64u, Error}; +use crate::{Error, b64u}; #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] diff --git a/proxmox-acme/src/jws.rs b/proxmox-acme/src/jws.rs index 7b172e2c..af9e0d8e 100644 --- a/proxmox-acme/src/jws.rs +++ b/proxmox-acme/src/jws.rs @@ -5,9 +5,9 @@ use openssl::pkey::{HasPrivate, PKeyRef}; use openssl::sign::Signer; use serde::Serialize; +use crate::Error; use crate::b64u; use crate::key::{Jwk, PublicKey}; -use crate::Error; #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] diff --git a/proxmox-acme/src/key.rs b/proxmox-acme/src/key.rs index 5dbc5460..ae790d04 100644 --- a/proxmox-acme/src/key.rs +++ b/proxmox-acme/src/key.rs @@ -4,8 +4,8 @@ use openssl::hash::{Hasher, MessageDigest}; use openssl::pkey::{HasPublic, Id, PKeyRef}; use serde::Serialize; -use crate::b64u; use crate::Error; +use crate::b64u; /// An RSA public key. #[derive(Clone, Debug, Serialize)] diff --git a/proxmox-acme/src/order.rs b/proxmox-acme/src/order.rs index b6551004..d75fbde1 100644 --- a/proxmox-acme/src/order.rs +++ b/proxmox-acme/src/order.rs @@ -3,8 +3,8 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; -use crate::request::Request; use crate::Error; +use crate::request::Request; /// Status of an [`Order`]. #[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize)] diff --git a/proxmox-api-macro/src/api/enums.rs b/proxmox-api-macro/src/api/enums.rs index 483686f2..33fc2f73 100644 --- a/proxmox-api-macro/src/api/enums.rs +++ b/proxmox-api-macro/src/api/enums.rs @@ -6,8 +6,8 @@ use proc_macro2::{Ident, Span, TokenStream}; use quote::quote_spanned; use syn::spanned::Spanned; -use super::attributes::EnumFieldAttributes; use super::Schema; +use super::attributes::EnumFieldAttributes; use crate::serde; use crate::util::{self, FieldName, JSONObject, JSONValue, Maybe}; diff --git a/proxmox-api-macro/src/api/method.rs b/proxmox-api-macro/src/api/method.rs index fdea5f35..5ef69e72 100644 --- a/proxmox-api-macro/src/api/method.rs +++ b/proxmox-api-macro/src/api/method.rs @@ -11,11 +11,11 @@ use std::mem; use anyhow::Error; use proc_macro2::{Span, TokenStream}; -use quote::{quote, quote_spanned, ToTokens}; +use quote::{ToTokens, quote, quote_spanned}; +use syn::Ident; use syn::ext::IdentExt; use syn::spanned::Spanned; use syn::visit_mut::{self, VisitMut}; -use syn::Ident; use super::{ObjectEntry, Schema, SchemaItem, SchemaObject}; use crate::util::{self, FieldName, JSONObject, JSONValue, Maybe}; @@ -93,11 +93,7 @@ impl TryFrom for ReturnSchema { Some(value) => { let span = value.span(); let is_optional: bool = value.try_into()?; - if is_optional { - Some(span) - } else { - None - } + if is_optional { Some(span) } else { None } } None => None, }; diff --git a/proxmox-api-macro/src/api/mod.rs b/proxmox-api-macro/src/api/mod.rs index 416ea56e..8078db07 100644 --- a/proxmox-api-macro/src/api/mod.rs +++ b/proxmox-api-macro/src/api/mod.rs @@ -12,7 +12,7 @@ use std::convert::{TryFrom, TryInto}; use anyhow::Error; use proc_macro2::{Span, TokenStream}; -use quote::{quote, quote_spanned, ToTokens}; +use quote::{ToTokens, quote, quote_spanned}; use syn::parse::{Parse, ParseStream, Parser}; use syn::spanned::Spanned; use syn::{Expr, ExprPath, Ident}; diff --git a/proxmox-api-macro/src/api/structs.rs b/proxmox-api-macro/src/api/structs.rs index c18b20b4..e11c68ad 100644 --- a/proxmox-api-macro/src/api/structs.rs +++ b/proxmox-api-macro/src/api/structs.rs @@ -18,8 +18,8 @@ use anyhow::Error; use proc_macro2::{Ident, Span, TokenStream}; use quote::quote_spanned; -use super::attributes::UpdaterFieldAttributes; use super::Schema; +use super::attributes::UpdaterFieldAttributes; use crate::api::{self, ObjectEntry, SchemaItem}; use crate::serde; use crate::util::{self, FieldName, JSONObject, Maybe}; diff --git a/proxmox-api-macro/src/serde.rs b/proxmox-api-macro/src/serde.rs index 345b3f2e..b2a4fc24 100644 --- a/proxmox-api-macro/src/serde.rs +++ b/proxmox-api-macro/src/serde.rs @@ -6,9 +6,9 @@ use std::convert::TryFrom; use proc_macro2::Span; +use syn::Token; use syn::punctuated::Punctuated; use syn::spanned::Spanned; -use syn::Token; /// Serde name types. #[allow(clippy::enum_variant_names)] diff --git a/proxmox-api-macro/src/util.rs b/proxmox-api-macro/src/util.rs index db2acdf2..74c436ce 100644 --- a/proxmox-api-macro/src/util.rs +++ b/proxmox-api-macro/src/util.rs @@ -4,10 +4,10 @@ use std::convert::TryFrom; use proc_macro2::{Ident, Span, TokenStream, TokenTree}; use quote::ToTokens; +use syn::Token; use syn::parse::{Parse, ParseStream}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; -use syn::Token; use anyhow::Error; diff --git a/proxmox-api-macro/tests/allof.rs b/proxmox-api-macro/tests/allof.rs index 57089d26..eaaf5606 100644 --- a/proxmox-api-macro/tests/allof.rs +++ b/proxmox-api-macro/tests/allof.rs @@ -2,7 +2,7 @@ use anyhow::Error; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use proxmox_api_macro::api; use proxmox_schema as schema; diff --git a/proxmox-api-macro/tests/api1.rs b/proxmox-api-macro/tests/api1.rs index cff0cd5b..125733fb 100644 --- a/proxmox-api-macro/tests/api1.rs +++ b/proxmox-api-macro/tests/api1.rs @@ -1,7 +1,7 @@ use proxmox_api_macro::api; use anyhow::Error; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use proxmox_router::Permission; diff --git a/proxmox-api-macro/tests/ext-schema.rs b/proxmox-api-macro/tests/ext-schema.rs index 4c88de0e..3e2d1cdf 100644 --- a/proxmox-api-macro/tests/ext-schema.rs +++ b/proxmox-api-macro/tests/ext-schema.rs @@ -6,7 +6,7 @@ use proxmox_router::RpcEnvironment; use proxmox_schema as schema; use anyhow::Error; -use serde_json::{json, Value}; +use serde_json::{Value, json}; pub const NAME_SCHEMA: schema::Schema = schema::StringSchema::new("Archive name.") //.format(&FILENAME_FORMAT) diff --git a/proxmox-api-macro/tests/options.rs b/proxmox-api-macro/tests/options.rs index 6a7fa1ba..6d61cc10 100644 --- a/proxmox-api-macro/tests/options.rs +++ b/proxmox-api-macro/tests/options.rs @@ -1,7 +1,7 @@ use proxmox_api_macro::api; use anyhow::Error; -use serde_json::{json, Value}; +use serde_json::{Value, json}; #[api( input: { diff --git a/proxmox-api-macro/tests/updater.rs b/proxmox-api-macro/tests/updater.rs index 43f97da2..b04abedf 100644 --- a/proxmox-api-macro/tests/updater.rs +++ b/proxmox-api-macro/tests/updater.rs @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize}; -use proxmox_schema::{api, ApiType, Updater, UpdaterType}; +use proxmox_schema::{ApiType, Updater, UpdaterType, api}; // Helpers for type checks: struct AssertTypeEq(T); diff --git a/proxmox-apt-api-types/src/lib.rs b/proxmox-apt-api-types/src/lib.rs index d3f5b3eb..0e147441 100644 --- a/proxmox-apt-api-types/src/lib.rs +++ b/proxmox-apt-api-types/src/lib.rs @@ -3,7 +3,7 @@ use std::fmt::Display; use serde::{Deserialize, Serialize}; use proxmox_config_digest::ConfigDigest; -use proxmox_schema::{api, const_regex, ApiStringFormat}; +use proxmox_schema::{ApiStringFormat, api, const_regex}; #[cfg(feature = "enum-fallback")] use proxmox_fixed_string::FixedString; diff --git a/proxmox-apt/src/api.rs b/proxmox-apt/src/api.rs index f5d4d3f9..b1d49658 100644 --- a/proxmox-apt/src/api.rs +++ b/proxmox-apt/src/api.rs @@ -1,7 +1,7 @@ // API function that work without feature "cache" use std::path::Path; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use proxmox_apt_api_types::{ APTChangeRepositoryOptions, APTGetChangelogOptions, APTRepositoriesResult, APTRepositoryFile, diff --git a/proxmox-apt/src/cache.rs b/proxmox-apt/src/cache.rs index b27fa886..c4fa801b 100644 --- a/proxmox-apt/src/cache.rs +++ b/proxmox-apt/src/cache.rs @@ -2,11 +2,11 @@ use std::collections::HashMap; use std::collections::HashSet; use std::path::Path; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use apt_pkg_native::Cache; use proxmox_schema::const_regex; -use proxmox_sys::fs::{file_read_optional_string, replace_file, CreateOptions}; +use proxmox_sys::fs::{CreateOptions, file_read_optional_string, replace_file}; use proxmox_apt_api_types::APTUpdateInfo; diff --git a/proxmox-apt/src/cache_api.rs b/proxmox-apt/src/cache_api.rs index 771c69ee..7856567b 100644 --- a/proxmox-apt/src/cache_api.rs +++ b/proxmox-apt/src/cache_api.rs @@ -1,7 +1,7 @@ // API function that need feature "cache" use std::path::Path; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use std::os::unix::prelude::OsStrExt; use proxmox_apt_api_types::{APTUpdateInfo, APTUpdateOptions}; diff --git a/proxmox-apt/src/deb822/mod.rs b/proxmox-apt/src/deb822/mod.rs index 59e7c210..d13c8670 100644 --- a/proxmox-apt/src/deb822/mod.rs +++ b/proxmox-apt/src/deb822/mod.rs @@ -1,5 +1,5 @@ mod release_file; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; pub use release_file::{CompressionType, FileReference, FileReferenceType, ReleaseFile}; mod packages_file; diff --git a/proxmox-apt/src/deb822/packages_file.rs b/proxmox-apt/src/deb822/packages_file.rs index aec0a926..7f691ebb 100644 --- a/proxmox-apt/src/deb822/packages_file.rs +++ b/proxmox-apt/src/deb822/packages_file.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use rfc822_like::de::Deserializer; use serde::Deserialize; use serde_json::Value; diff --git a/proxmox-apt/src/deb822/release_file.rs b/proxmox-apt/src/deb822/release_file.rs index 54e4afa8..9af51828 100644 --- a/proxmox-apt/src/deb822/release_file.rs +++ b/proxmox-apt/src/deb822/release_file.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use rfc822_like::de::Deserializer; use serde::Deserialize; use serde_json::Value; diff --git a/proxmox-apt/src/deb822/sources_file.rs b/proxmox-apt/src/deb822/sources_file.rs index 40bef6e0..3893350e 100644 --- a/proxmox-apt/src/deb822/sources_file.rs +++ b/proxmox-apt/src/deb822/sources_file.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use rfc822_like::de::Deserializer; use serde::Deserialize; use serde_json::Value; diff --git a/proxmox-apt/src/repositories/file.rs b/proxmox-apt/src/repositories/file.rs index b0e426c2..e143b4c7 100644 --- a/proxmox-apt/src/repositories/file.rs +++ b/proxmox-apt/src/repositories/file.rs @@ -1,6 +1,6 @@ use std::path::{Path, PathBuf}; -use anyhow::{format_err, Error}; +use anyhow::{Error, format_err}; use crate::repositories::release::DebianCodename; use proxmox_apt_api_types::{ diff --git a/proxmox-apt/src/repositories/file/list_parser.rs b/proxmox-apt/src/repositories/file/list_parser.rs index 7a0e23a5..df898676 100644 --- a/proxmox-apt/src/repositories/file/list_parser.rs +++ b/proxmox-apt/src/repositories/file/list_parser.rs @@ -1,7 +1,7 @@ use std::io::BufRead; use std::iter::Iterator; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use super::APTRepositoryParser; use crate::repositories::APTRepositoryImpl; diff --git a/proxmox-apt/src/repositories/file/sources_parser.rs b/proxmox-apt/src/repositories/file/sources_parser.rs index 498271fb..17bc0ca7 100644 --- a/proxmox-apt/src/repositories/file/sources_parser.rs +++ b/proxmox-apt/src/repositories/file/sources_parser.rs @@ -1,7 +1,7 @@ use std::io::BufRead; use std::iter::Iterator; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use crate::repositories::APTRepositoryImpl; use crate::repositories::{ diff --git a/proxmox-apt/src/repositories/mod.rs b/proxmox-apt/src/repositories/mod.rs index 2b52c774..99f29d87 100644 --- a/proxmox-apt/src/repositories/mod.rs +++ b/proxmox-apt/src/repositories/mod.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use std::path::{Path, PathBuf}; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; mod repository; use proxmox_apt_api_types::{ @@ -16,7 +16,7 @@ mod file; pub use file::APTRepositoryFileImpl; mod release; -pub use release::{get_current_release_codename, DebianCodename}; +pub use release::{DebianCodename, get_current_release_codename}; mod standard; pub use standard::{APTRepositoryHandleImpl, APTStandardRepositoryImpl}; diff --git a/proxmox-apt/src/repositories/release.rs b/proxmox-apt/src/repositories/release.rs index c191cb32..c1ebba6a 100644 --- a/proxmox-apt/src/repositories/release.rs +++ b/proxmox-apt/src/repositories/release.rs @@ -1,7 +1,7 @@ use std::fmt::Display; use std::io::{BufRead, BufReader}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; /// The code names of Debian releases. Does not include `sid`. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] diff --git a/proxmox-apt/src/repositories/repository.rs b/proxmox-apt/src/repositories/repository.rs index 57fe16da..810d5d39 100644 --- a/proxmox-apt/src/repositories/repository.rs +++ b/proxmox-apt/src/repositories/repository.rs @@ -1,7 +1,7 @@ use std::io::{BufRead, BufReader, Write}; use std::path::{Path, PathBuf}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use crate::repositories::standard::APTRepositoryHandleImpl; use proxmox_apt_api_types::{ diff --git a/proxmox-apt/tests/repositories.rs b/proxmox-apt/tests/repositories.rs index 43f32b27..3ba14925 100644 --- a/proxmox-apt/tests/repositories.rs +++ b/proxmox-apt/tests/repositories.rs @@ -1,12 +1,12 @@ use std::path::PathBuf; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use proxmox_apt::repositories::{ - check_repositories, get_current_release_codename, standard_repositories, DebianCodename, + APTRepositoryFileImpl, APTRepositoryImpl, APTStandardRepositoryImpl, }; use proxmox_apt::repositories::{ - APTRepositoryFileImpl, APTRepositoryImpl, APTStandardRepositoryImpl, + DebianCodename, check_repositories, get_current_release_codename, standard_repositories, }; use proxmox_apt_api_types::{ APTRepositoryFile, APTRepositoryHandle, APTRepositoryInfo, APTStandardRepository, diff --git a/proxmox-async/src/broadcast_future.rs b/proxmox-async/src/broadcast_future.rs index 9c4d77ce..e33deb12 100644 --- a/proxmox-async/src/broadcast_future.rs +++ b/proxmox-async/src/broadcast_future.rs @@ -4,7 +4,7 @@ use std::future::Future; use std::pin::Pin; use std::sync::{Arc, Mutex}; -use anyhow::{format_err, Error}; +use anyhow::{Error, format_err}; use futures::future::{FutureExt, TryFutureExt}; use tokio::sync::oneshot; @@ -44,7 +44,7 @@ impl BroadcastData { } pub fn listen(&mut self) -> impl Future> + use { - use futures::future::{ok, Either}; + use futures::future::{Either, ok}; match &self.result { None => {} diff --git a/proxmox-auth-api/examples/passwd.rs b/proxmox-auth-api/examples/passwd.rs index 27816271..58397b28 100644 --- a/proxmox-auth-api/examples/passwd.rs +++ b/proxmox-auth-api/examples/passwd.rs @@ -5,7 +5,7 @@ use std::io::Write; use std::pin::Pin; use std::task::{Context, Poll}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use proxmox_auth_api::api::Authenticator; use proxmox_auth_api::types::Username; diff --git a/proxmox-auth-api/src/api/access.rs b/proxmox-auth-api/src/api/access.rs index fe416250..d6edb1ad 100644 --- a/proxmox-auth-api/src/api/access.rs +++ b/proxmox-auth-api/src/api/access.rs @@ -1,20 +1,20 @@ //! Provides the "/access/ticket" API call. -use anyhow::{bail, format_err, Error}; -use http::request::Parts; +use anyhow::{Error, bail, format_err}; use http::Response; +use http::request::Parts; use openssl::hash::MessageDigest; -use serde_json::{json, Value}; +use serde_json::{Value, json}; -use proxmox_rest_server::{extract_cookie, RestEnvironment}; +use proxmox_rest_server::{RestEnvironment, extract_cookie}; use proxmox_router::{ - http_err, ApiHandler, ApiMethod, ApiResponseFuture, Permission, RpcEnvironment, + ApiHandler, ApiMethod, ApiResponseFuture, Permission, RpcEnvironment, http_err, }; -use proxmox_schema::{api, AllOfSchema, ApiType, ObjectSchema, ParameterSchema, ReturnType}; +use proxmox_schema::{AllOfSchema, ApiType, ObjectSchema, ParameterSchema, ReturnType, api}; use proxmox_tfa::api::TfaChallenge; use super::ApiTicket; -use super::{auth_context, HMACKey}; +use super::{HMACKey, auth_context}; use crate::ticket::Ticket; use crate::types::{Authid, CreateTicket, CreateTicketResponse, Userid, VerifyVNCTicket}; diff --git a/proxmox-auth-api/src/api/mod.rs b/proxmox-auth-api/src/api/mod.rs index 98cf77e9..9f221aac 100644 --- a/proxmox-auth-api/src/api/mod.rs +++ b/proxmox-auth-api/src/api/mod.rs @@ -3,10 +3,10 @@ use std::net::IpAddr; use std::pin::Pin; use std::sync::{Mutex, OnceLock}; -use anyhow::{format_err, Error}; +use anyhow::{Error, format_err}; use percent_encoding::percent_decode_str; -use proxmox_rest_server::{extract_cookie, AuthError}; +use proxmox_rest_server::{AuthError, extract_cookie}; use proxmox_tfa::api::{OpenUserChallengeData, TfaConfig}; use crate::auth_key::{HMACKey, Keyring}; @@ -19,8 +19,8 @@ use crate::ticket::Ticket; use access::verify_csrf_prevention_token; pub use access::{ - assemble_csrf_prevention_token, create_ticket, verify_vnc_ticket, API_METHOD_CREATE_TICKET, - API_METHOD_CREATE_TICKET_HTTP_ONLY, API_METHOD_LOGOUT, API_METHOD_VERIFY_VNC_TICKET, + API_METHOD_CREATE_TICKET, API_METHOD_CREATE_TICKET_HTTP_ONLY, API_METHOD_LOGOUT, + API_METHOD_VERIFY_VNC_TICKET, assemble_csrf_prevention_token, create_ticket, verify_vnc_ticket, }; pub use ticket::{ApiTicket, PartialTicket}; diff --git a/proxmox-auth-api/src/api/ticket.rs b/proxmox-auth-api/src/api/ticket.rs index 279cd127..01687201 100644 --- a/proxmox-auth-api/src/api/ticket.rs +++ b/proxmox-auth-api/src/api/ticket.rs @@ -2,7 +2,7 @@ use std::fmt; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use serde::{Deserialize, Serialize}; use proxmox_tfa::api::TfaChallenge; diff --git a/proxmox-auth-api/src/auth_key.rs b/proxmox-auth-api/src/auth_key.rs index 667deaaf..060a5610 100644 --- a/proxmox-auth-api/src/auth_key.rs +++ b/proxmox-auth-api/src/auth_key.rs @@ -1,6 +1,6 @@ //! Auth key handling. -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use openssl::hash::MessageDigest; use openssl::pkey::{HasPublic, Id, PKey, PKeyRef, Private, Public}; use openssl::rsa::Rsa; diff --git a/proxmox-auth-api/src/pam_authenticator.rs b/proxmox-auth-api/src/pam_authenticator.rs index ed8708da..6c232d2f 100644 --- a/proxmox-auth-api/src/pam_authenticator.rs +++ b/proxmox-auth-api/src/pam_authenticator.rs @@ -1,9 +1,9 @@ -use std::ffi::{c_int, c_void, CStr, CString}; +use std::ffi::{CStr, CString, c_int, c_void}; use std::future::Future; use std::net::IpAddr; use std::pin::Pin; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use pam_sys::types::{ PamHandle, PamItemType, PamMessage, PamMessageStyle, PamResponse, PamReturnCode, }; diff --git a/proxmox-auth-api/src/password_authenticator.rs b/proxmox-auth-api/src/password_authenticator.rs index 06b6551a..6a946bb0 100644 --- a/proxmox-auth-api/src/password_authenticator.rs +++ b/proxmox-auth-api/src/password_authenticator.rs @@ -2,7 +2,7 @@ use std::future::Future; use std::net::IpAddr; use std::pin::Pin; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use serde_json::json; use proxmox_product_config::open_secret_lockfile; diff --git a/proxmox-auth-api/src/ticket.rs b/proxmox-auth-api/src/ticket.rs index 98e93ef6..5c90e42d 100644 --- a/proxmox-auth-api/src/ticket.rs +++ b/proxmox-auth-api/src/ticket.rs @@ -4,9 +4,9 @@ use std::borrow::Cow; use std::fmt; use std::marker::PhantomData; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use openssl::hash::MessageDigest; -use percent_encoding::{percent_decode_str, percent_encode, AsciiSet}; +use percent_encoding::{AsciiSet, percent_decode_str, percent_encode}; use crate::auth_key::Keyring; diff --git a/proxmox-auth-api/src/types.rs b/proxmox-auth-api/src/types.rs index ba3fda5d..eb15ff49 100644 --- a/proxmox-auth-api/src/types.rs +++ b/proxmox-auth-api/src/types.rs @@ -25,12 +25,12 @@ use std::borrow::Borrow; use std::fmt; use std::sync::LazyLock; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use const_format::concatcp; use serde::{Deserialize, Serialize}; use proxmox_schema::{ - api, const_regex, ApiStringFormat, ApiType, Schema, StringSchema, UpdaterType, + ApiStringFormat, ApiType, Schema, StringSchema, UpdaterType, api, const_regex, }; use proxmox_schema::api_types::SAFE_ID_REGEX_STR; diff --git a/proxmox-base64/src/implementation.rs b/proxmox-base64/src/implementation.rs index 4e7d131c..d7f489d4 100644 --- a/proxmox-base64/src/implementation.rs +++ b/proxmox-base64/src/implementation.rs @@ -27,9 +27,9 @@ macro_rules! implement_kind { ) => { use std::fmt; - use base64::engine::general_purpose::{GeneralPurpose, GeneralPurposeConfig}; use base64::engine::DecodePaddingMode; use base64::engine::Engine as _; + use base64::engine::general_purpose::{GeneralPurpose, GeneralPurposeConfig}; #[cfg(feature = "serde")] use serde::{Deserialize, Deserializer, Serializer}; diff --git a/proxmox-client/src/client.rs b/proxmox-client/src/client.rs index 81af5681..34e26e35 100644 --- a/proxmox-client/src/client.rs +++ b/proxmox-client/src/client.rs @@ -4,9 +4,9 @@ use std::pin::Pin; use std::sync::Arc; use std::sync::Mutex; +use http::Method; use http::request::Request; use http::uri::PathAndQuery; -use http::Method; use http::{StatusCode, Uri}; use http_body_util::BodyExt; use openssl::hash::MessageDigest; diff --git a/proxmox-compression/src/zip.rs b/proxmox-compression/src/zip.rs index 51a8f8f8..1ee4e819 100644 --- a/proxmox-compression/src/zip.rs +++ b/proxmox-compression/src/zip.rs @@ -14,7 +14,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use std::time::SystemTime; -use anyhow::{format_err, Error, Result}; +use anyhow::{Error, Result, format_err}; use endian_trait::Endian; use futures::ready; use libc::{S_IFDIR, S_IFLNK, S_IFREG}; diff --git a/proxmox-compression/src/zstd.rs b/proxmox-compression/src/zstd.rs index 7e303833..471d65ec 100644 --- a/proxmox-compression/src/zstd.rs +++ b/proxmox-compression/src/zstd.rs @@ -3,7 +3,7 @@ use std::io; use std::pin::Pin; use std::task::{Context, Poll}; -use anyhow::{format_err, Error}; +use anyhow::{Error, format_err}; use bytes::Bytes; use futures::ready; use futures::stream::Stream; diff --git a/proxmox-compression/tests/zip.rs b/proxmox-compression/tests/zip.rs index db7aa171..995fa326 100644 --- a/proxmox-compression/tests/zip.rs +++ b/proxmox-compression/tests/zip.rs @@ -1,6 +1,6 @@ use std::io::Cursor; -use anyhow::{ensure, Result}; +use anyhow::{Result, ensure}; use flate2::{Decompress, FlushDecompress}; use tokio::test; diff --git a/proxmox-config-digest/src/lib.rs b/proxmox-config-digest/src/lib.rs index 0b113f21..002bdc4a 100644 --- a/proxmox-config-digest/src/lib.rs +++ b/proxmox-config-digest/src/lib.rs @@ -1,15 +1,15 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; #[cfg(feature = "openssl")] use openssl::sha; -use proxmox_schema::api_types::SHA256_HEX_REGEX; use proxmox_schema::ApiStringFormat; use proxmox_schema::ApiType; use proxmox_schema::Schema; use proxmox_schema::StringSchema; +use proxmox_schema::api_types::SHA256_HEX_REGEX; pub const PROXMOX_CONFIG_DIGEST_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&SHA256_HEX_REGEX); diff --git a/proxmox-daemon/src/command_socket.rs b/proxmox-daemon/src/command_socket.rs index b09070c2..1795e92c 100644 --- a/proxmox-daemon/src/command_socket.rs +++ b/proxmox-daemon/src/command_socket.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use std::collections::HashMap; use std::future::Future; diff --git a/proxmox-daemon/src/server.rs b/proxmox-daemon/src/server.rs index a1023d1d..ff68ba44 100644 --- a/proxmox-daemon/src/server.rs +++ b/proxmox-daemon/src/server.rs @@ -7,11 +7,11 @@ use std::os::unix::ffi::OsStrExt; use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; use std::panic::UnwindSafe; use std::path::PathBuf; -use std::pin::{pin, Pin}; +use std::pin::{Pin, pin}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use futures::future::{self, Either}; -use nix::unistd::{fork, ForkResult}; +use nix::unistd::{ForkResult, fork}; use proxmox_sys::fd::fd_change_cloexec; use proxmox_sys::fs::CreateOptions; diff --git a/proxmox-daemon/src/state.rs b/proxmox-daemon/src/state.rs index f5d23bcf..e1bde586 100644 --- a/proxmox-daemon/src/state.rs +++ b/proxmox-daemon/src/state.rs @@ -1,10 +1,10 @@ use std::future::Future; use std::pin::pin; -use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::OnceLock; +use std::sync::atomic::{AtomicBool, Ordering}; -use anyhow::{bail, Error}; -use tokio::signal::unix::{signal, SignalKind}; +use anyhow::{Error, bail}; +use tokio::signal::unix::{SignalKind, signal}; use tokio::sync::watch; static SHUTDOWN_LISTENERS: OnceLock> = OnceLock::new(); diff --git a/proxmox-dns-api/src/api_types.rs b/proxmox-dns-api/src/api_types.rs index f0ff70f4..20d8bdf9 100644 --- a/proxmox-dns-api/src/api_types.rs +++ b/proxmox-dns-api/src/api_types.rs @@ -1,9 +1,9 @@ use serde::{Deserialize, Serialize}; -use proxmox_schema::api; -use proxmox_schema::api_types::IP_FORMAT; use proxmox_schema::Schema; use proxmox_schema::StringSchema; +use proxmox_schema::api; +use proxmox_schema::api_types::IP_FORMAT; use proxmox_config_digest::ConfigDigest; diff --git a/proxmox-dns-api/src/resolv_conf.rs b/proxmox-dns-api/src/resolv_conf.rs index 9b51f013..29773105 100644 --- a/proxmox-dns-api/src/resolv_conf.rs +++ b/proxmox-dns-api/src/resolv_conf.rs @@ -5,9 +5,9 @@ use const_format::concatcp; use proxmox_config_digest::ConfigDigest; use regex::Regex; +use proxmox_sys::fs::CreateOptions; use proxmox_sys::fs::file_get_contents; use proxmox_sys::fs::replace_file; -use proxmox_sys::fs::CreateOptions; use proxmox_schema::api_types::IPRE_STR; diff --git a/proxmox-docgen/src/lib.rs b/proxmox-docgen/src/lib.rs index f4e7bf1e..3ee691fc 100644 --- a/proxmox-docgen/src/lib.rs +++ b/proxmox-docgen/src/lib.rs @@ -1,4 +1,4 @@ -use serde_json::{json, Value}; +use serde_json::{Value, json}; use proxmox_router::{ApiAccess, ApiHandler, ApiMethod, Permission, Router, SubRoute}; use proxmox_schema::format::get_property_string_type_text; diff --git a/proxmox-http-error/src/lib.rs b/proxmox-http-error/src/lib.rs index a8ccff7f..ea404845 100644 --- a/proxmox-http-error/src/lib.rs +++ b/proxmox-http-error/src/lib.rs @@ -2,7 +2,7 @@ use std::fmt; -use serde::{ser::SerializeStruct, Serialize, Serializer}; +use serde::{Serialize, Serializer, ser::SerializeStruct}; #[doc(hidden)] pub use http::StatusCode; diff --git a/proxmox-http/src/client/connector.rs b/proxmox-http/src/client/connector.rs index 70efd23d..0b8ff37e 100644 --- a/proxmox-http/src/client/connector.rs +++ b/proxmox-http/src/client/connector.rs @@ -1,12 +1,12 @@ -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use futures::*; use http::Uri; -use hyper_util::client::legacy::connect::dns::{GaiResolver, Name}; use hyper_util::client::legacy::connect::HttpConnector; +use hyper_util::client::legacy::connect::dns::{GaiResolver, Name}; use hyper_util::rt::TokioIo; use openssl::ssl::SslConnector; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; diff --git a/proxmox-http/src/client/simple.rs b/proxmox-http/src/client/simple.rs index a0db497c..0ea77768 100644 --- a/proxmox-http/src/client/simple.rs +++ b/proxmox-http/src/client/simple.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use std::collections::HashMap; use std::fmt::Display; @@ -12,15 +12,15 @@ use futures::*; use http::{HeaderValue, Request, Response}; use http_body_util::{BodyDataStream, BodyExt}; -use hyper_util::client::legacy::connect::dns::GaiResolver; -use hyper_util::client::legacy::connect::HttpConnector; use hyper_util::client::legacy::Client as HyperClient; +use hyper_util::client::legacy::connect::HttpConnector; +use hyper_util::client::legacy::connect::dns::GaiResolver; use hyper_util::rt::TokioExecutor; use openssl::ssl::{SslConnector, SslMethod}; -use crate::client::HttpsConnector; use crate::Body; use crate::HttpOptions; +use crate::client::HttpsConnector; /// Asynchronous HTTP client implementation pub struct Client { @@ -338,8 +338,8 @@ si aliquod aeternum et infinitum impendere."#; } fn encode_deflate(bytes: &[u8]) -> Result, std::io::Error> { - use flate2::write::ZlibEncoder; use flate2::Compression; + use flate2::write::ZlibEncoder; let mut e = ZlibEncoder::new(Vec::new(), Compression::default()); e.write_all(bytes).unwrap(); diff --git a/proxmox-http/src/proxy_config.rs b/proxmox-http/src/proxy_config.rs index 7ec68998..b32cff9a 100644 --- a/proxmox-http/src/proxy_config.rs +++ b/proxmox-http/src/proxy_config.rs @@ -2,7 +2,7 @@ //! //! This can be used with the async [`Client`](crate::client::Client) or sync [`Client`](crate::client::sync::Client). -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use http::Uri; diff --git a/proxmox-http/src/uri.rs b/proxmox-http/src/uri.rs index cce47e67..ae2458da 100644 --- a/proxmox-http/src/uri.rs +++ b/proxmox-http/src/uri.rs @@ -1,8 +1,8 @@ //! URI Related helpers, such as `build_authority` +use anyhow::Error; use anyhow::bail; use anyhow::format_err; -use anyhow::Error; use http::uri::{Authority, InvalidUri}; use serde_json::Value; diff --git a/proxmox-http/src/websocket/mod.rs b/proxmox-http/src/websocket/mod.rs index 88d25f44..7d138d92 100644 --- a/proxmox-http/src/websocket/mod.rs +++ b/proxmox-http/src/websocket/mod.rs @@ -9,10 +9,10 @@ use std::io; use std::pin::Pin; use std::task::{Context, Poll}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use futures::select; use http::header::{ - HeaderMap, HeaderValue, CONNECTION, SEC_WEBSOCKET_ACCEPT, SEC_WEBSOCKET_KEY, + CONNECTION, HeaderMap, HeaderValue, SEC_WEBSOCKET_ACCEPT, SEC_WEBSOCKET_KEY, SEC_WEBSOCKET_PROTOCOL, SEC_WEBSOCKET_VERSION, UPGRADE, }; use http::{Response, StatusCode}; diff --git a/proxmox-human-byte/src/lib.rs b/proxmox-human-byte/src/lib.rs index ab5d0627..25b46321 100644 --- a/proxmox-human-byte/src/lib.rs +++ b/proxmox-human-byte/src/lib.rs @@ -1,6 +1,6 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use proxmox_schema::{ApiStringFormat, ApiType, Schema, StringSchema, UpdaterType}; diff --git a/proxmox-io/src/lib.rs b/proxmox-io/src/lib.rs index a05b9232..bd31ebc5 100644 --- a/proxmox-io/src/lib.rs +++ b/proxmox-io/src/lib.rs @@ -16,7 +16,7 @@ mod write; pub use write::WriteExt; mod sparse_copy; -pub use sparse_copy::{buffer_is_zero, sparse_copy, SparseCopyResult}; +pub use sparse_copy::{SparseCopyResult, buffer_is_zero, sparse_copy}; #[cfg(feature = "tokio")] pub use sparse_copy::sparse_copy_async; diff --git a/proxmox-lang/src/lib.rs b/proxmox-lang/src/lib.rs index 0abfd507..7e9b2200 100644 --- a/proxmox-lang/src/lib.rs +++ b/proxmox-lang/src/lib.rs @@ -102,7 +102,5 @@ macro_rules! offsetof { #[deprecated = "use c\"literals\" instead"] #[macro_export] macro_rules! c_str { - ($data:expr) => {{ - unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(concat!($data, "\0").as_bytes()) } - }}; + ($data:expr) => {{ unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(concat!($data, "\0").as_bytes()) } }}; } diff --git a/proxmox-ldap/src/lib.rs b/proxmox-ldap/src/lib.rs index 12d88291..d9066e9b 100644 --- a/proxmox-ldap/src/lib.rs +++ b/proxmox-ldap/src/lib.rs @@ -8,7 +8,7 @@ use std::{ time::Duration, }; -use anyhow::{bail, format_err, Context, Error}; +use anyhow::{Context, Error, bail, format_err}; use ldap3::adapters::{Adapter, EntriesOnly, PagedResults}; use ldap3::{Ldap, LdapConnAsync, LdapConnSettings, LdapResult, Scope, SearchEntry}; use native_tls::{Certificate, TlsConnector, TlsConnectorBuilder}; diff --git a/proxmox-ldap/src/sync.rs b/proxmox-ldap/src/sync.rs index e5bfdf3e..c50f8393 100644 --- a/proxmox-ldap/src/sync.rs +++ b/proxmox-ldap/src/sync.rs @@ -1,10 +1,10 @@ use std::collections::HashSet; -use anyhow::{format_err, Context, Error}; +use anyhow::{Context, Error, format_err}; use proxmox_access_control::acl::AclTree; use proxmox_access_control::types::{ - ApiToken, User, EMAIL_SCHEMA, FIRST_NAME_SCHEMA, LAST_NAME_SCHEMA, + ApiToken, EMAIL_SCHEMA, FIRST_NAME_SCHEMA, LAST_NAME_SCHEMA, User, }; use proxmox_auth_api::types::{Authid, Realm, Userid}; use proxmox_product_config::ApiLockGuard; @@ -12,8 +12,8 @@ use proxmox_schema::{ApiType, Schema}; use proxmox_section_config::SectionConfigData; use crate::types::{ - AdRealmConfig, LdapRealmConfig, RemoveVanished, SyncAttributes, SyncDefaultsOptions, - REMOVE_VANISHED_ARRAY, USER_CLASSES_ARRAY, + AdRealmConfig, LdapRealmConfig, REMOVE_VANISHED_ARRAY, RemoveVanished, SyncAttributes, + SyncDefaultsOptions, USER_CLASSES_ARRAY, }; use crate::{Config, Connection, SearchResult}; diff --git a/proxmox-ldap/src/types.rs b/proxmox-ldap/src/types.rs index 8c7f2dca..a7431fc9 100644 --- a/proxmox-ldap/src/types.rs +++ b/proxmox-ldap/src/types.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use proxmox_schema::api_types::{COMMENT_SCHEMA, SAFE_ID_FORMAT}; -use proxmox_schema::{api, ApiStringFormat, ApiType, ArraySchema, Schema, StringSchema, Updater}; +use proxmox_schema::{ApiStringFormat, ApiType, ArraySchema, Schema, StringSchema, Updater, api}; pub const REALM_ID_SCHEMA: Schema = StringSchema::new("Realm name.") .format(&SAFE_ID_FORMAT) @@ -257,8 +257,7 @@ pub const SYNC_DEFAULTS_STRING_SCHEMA: Schema = StringSchema::new("sync defaults )) .schema(); -const REMOVE_VANISHED_DESCRIPTION: &str = - "A semicolon-separated list of things to remove when they or the user \ +const REMOVE_VANISHED_DESCRIPTION: &str = "A semicolon-separated list of things to remove when they or the user \ vanishes during user synchronization. The following values are possible: ``entry`` removes the \ user when not returned from the sync; ``properties`` removes any \ properties on existing user that do not appear in the source. \ diff --git a/proxmox-ldap/tests/glauth.rs b/proxmox-ldap/tests/glauth.rs index d497018c..5ec5d7e8 100644 --- a/proxmox-ldap/tests/glauth.rs +++ b/proxmox-ldap/tests/glauth.rs @@ -151,13 +151,14 @@ fn test_search() -> Result<(), Error> { assert!(a.dn.starts_with("cn=test")); assert!(a.dn.ends_with("ou=testgroup,ou=users,dc=example,dc=com")); - assert!(a - .attributes - .get("mail") - .unwrap() - .first() - .unwrap() - .ends_with("@example.com")); + assert!( + a.attributes + .get("mail") + .unwrap() + .first() + .unwrap() + .ends_with("@example.com") + ); assert!(a.attributes.get("sn").unwrap().first().unwrap().eq("User")); } diff --git a/proxmox-log/src/builder.rs b/proxmox-log/src/builder.rs index 70616ce7..6fcf1cc9 100644 --- a/proxmox-log/src/builder.rs +++ b/proxmox-log/src/builder.rs @@ -1,15 +1,15 @@ -use tracing::level_filters::LevelFilter; use tracing::Level; use tracing::Metadata; +use tracing::level_filters::LevelFilter; use tracing_log::{AsLog, LogTracer}; +use tracing_subscriber::Layer; use tracing_subscriber::layer::Context; use tracing_subscriber::layer::Filter; use tracing_subscriber::layer::SubscriberExt; -use tracing_subscriber::Layer; use crate::{ - get_env_variable, journald_or_stderr_layer, plain_stderr_layer, - pve_task_formatter::PveTaskFormatter, tasklog_layer::TasklogLayer, LogContext, + LogContext, get_env_variable, journald_or_stderr_layer, plain_stderr_layer, + pve_task_formatter::PveTaskFormatter, tasklog_layer::TasklogLayer, }; /// /// Filter yielding `true` *outside* of worker tasks, *unless* the level is `ERROR`. diff --git a/proxmox-log/src/file_logger.rs b/proxmox-log/src/file_logger.rs index 39d16857..2d0c0d0c 100644 --- a/proxmox-log/src/file_logger.rs +++ b/proxmox-log/src/file_logger.rs @@ -3,7 +3,7 @@ use std::io::Write; use anyhow::Error; use nix::fcntl::OFlag; -use proxmox_sys::fs::{atomic_open_or_create_file, CreateOptions}; +use proxmox_sys::fs::{CreateOptions, atomic_open_or_create_file}; /// Options to control the behavior of a [FileLogger] instance #[derive(Default)] diff --git a/proxmox-log/src/lib.rs b/proxmox-log/src/lib.rs index 3a529cca..2d321f20 100644 --- a/proxmox-log/src/lib.rs +++ b/proxmox-log/src/lib.rs @@ -17,6 +17,7 @@ pub mod builder; pub use builder::Logger; pub use file_logger::{FileLogOptions, FileLogger}; +pub use tracing::Level; pub use tracing::debug; pub use tracing::debug_span; pub use tracing::enabled; @@ -31,7 +32,6 @@ pub use tracing::trace; pub use tracing::trace_span; pub use tracing::warn; pub use tracing::warn_span; -pub use tracing::Level; pub use tracing_subscriber::filter::LevelFilter; tokio::task_local! { diff --git a/proxmox-log/src/tasklog_layer.rs b/proxmox-log/src/tasklog_layer.rs index 48fd7c1e..d2b7ffc5 100644 --- a/proxmox-log/src/tasklog_layer.rs +++ b/proxmox-log/src/tasklog_layer.rs @@ -1,12 +1,12 @@ use std::fmt::Write as _; -use tracing::field::Field; -use tracing::field::Visit; use tracing::Event; use tracing::Level; use tracing::Subscriber; -use tracing_subscriber::layer::Context; +use tracing::field::Field; +use tracing::field::Visit; use tracing_subscriber::Layer; +use tracing_subscriber::layer::Context; use crate::{FileLogState, LogContext}; diff --git a/proxmox-metrics/src/influxdb/http.rs b/proxmox-metrics/src/influxdb/http.rs index 904868ae..2bb7798d 100644 --- a/proxmox-metrics/src/influxdb/http.rs +++ b/proxmox-metrics/src/influxdb/http.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode}; use tokio::sync::mpsc; diff --git a/proxmox-metrics/src/influxdb/utils.rs b/proxmox-metrics/src/influxdb/utils.rs index 05e304f4..0f9a7288 100644 --- a/proxmox-metrics/src/influxdb/utils.rs +++ b/proxmox-metrics/src/influxdb/utils.rs @@ -1,6 +1,6 @@ use std::fmt::Write; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use serde_json::Value; use crate::MetricsData; diff --git a/proxmox-metrics/src/lib.rs b/proxmox-metrics/src/lib.rs index 84e7f07d..cf7bc814 100644 --- a/proxmox-metrics/src/lib.rs +++ b/proxmox-metrics/src/lib.rs @@ -4,7 +4,7 @@ use std::borrow::Cow; use std::collections::HashMap; use std::sync::Arc; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use serde::Serialize; use serde_json::Value; use tokio::sync::mpsc; diff --git a/proxmox-network-api/src/api_impl.rs b/proxmox-network-api/src/api_impl.rs index 50dc46af..9d956e2c 100644 --- a/proxmox-network-api/src/api_impl.rs +++ b/proxmox-network-api/src/api_impl.rs @@ -1,12 +1,12 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use proxmox_config_digest::ConfigDigest; -use crate::{parse_vlan_id_from_name, parse_vlan_raw_device_from_name}; use crate::{ DeletableInterfaceProperty, Interface, InterfaceUpdater, LinuxBondMode, NetworkConfigMethod, NetworkInterfaceType, }; +use crate::{parse_vlan_id_from_name, parse_vlan_raw_device_from_name}; /// Create network interface configuration. pub fn create_interface(iface: String, config: InterfaceUpdater) -> Result<(), Error> { diff --git a/proxmox-network-api/src/api_types.rs b/proxmox-network-api/src/api_types.rs index 4860a114..afff25cb 100644 --- a/proxmox-network-api/src/api_types.rs +++ b/proxmox-network-api/src/api_types.rs @@ -1,16 +1,16 @@ use std::fmt; use std::sync::LazyLock; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use serde::{Deserialize, Serialize}; use regex::Regex; -use proxmox_schema::api_types::SAFE_ID_REGEX; use proxmox_schema::ApiStringFormat; use proxmox_schema::ArraySchema; use proxmox_schema::Schema; use proxmox_schema::StringSchema; +use proxmox_schema::api_types::SAFE_ID_REGEX; pub use proxmox_schema::api; pub use proxmox_schema::api_types::{CIDR_SCHEMA, CIDR_V4_SCHEMA, CIDR_V6_SCHEMA}; diff --git a/proxmox-network-api/src/config/helper.rs b/proxmox-network-api/src/config/helper.rs index cc2f3dd0..a9ae35fc 100644 --- a/proxmox-network-api/src/config/helper.rs +++ b/proxmox-network-api/src/config/helper.rs @@ -3,7 +3,7 @@ use std::path::Path; use std::process::Command; use std::sync::LazyLock; -use anyhow::{bail, format_err, Context, Error}; +use anyhow::{Context, Error, bail, format_err}; use const_format::concatcp; use regex::Regex; diff --git a/proxmox-network-api/src/config/mod.rs b/proxmox-network-api/src/config/mod.rs index 9b9f0d50..95be1396 100644 --- a/proxmox-network-api/src/config/mod.rs +++ b/proxmox-network-api/src/config/mod.rs @@ -2,15 +2,15 @@ mod helper; mod lexer; mod parser; -pub use helper::{assert_ifupdown2_installed, network_reload, parse_cidr, AltnameMapping, IpLink}; +pub use helper::{AltnameMapping, IpLink, assert_ifupdown2_installed, network_reload, parse_cidr}; use std::collections::{BTreeMap, HashMap, HashSet}; use std::io::Write; use std::sync::LazyLock; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use regex::Regex; -use serde::de::{value, Deserialize, IntoDeserializer}; +use serde::de::{Deserialize, IntoDeserializer, value}; use super::{ BondXmitHashPolicy, Interface, LinuxBondMode, NetworkConfigMethod, NetworkInterfaceType, @@ -21,7 +21,7 @@ pub use helper::get_network_interfaces; use parser::NetworkParser; use proxmox_config_digest::ConfigDigest; -use proxmox_product_config::{open_api_lockfile, replace_system_config, ApiLockGuard}; +use proxmox_product_config::{ApiLockGuard, open_api_lockfile, replace_system_config}; static PHYSICAL_NIC_REGEX: LazyLock = LazyLock::new(|| Regex::new(r"^(?:eth\d+|en[^:.]+|ib\d+)$").unwrap()); diff --git a/proxmox-network-api/src/config/parser.rs b/proxmox-network-api/src/config/parser.rs index 8cbc6ac8..a2af1481 100644 --- a/proxmox-network-api/src/config/parser.rs +++ b/proxmox-network-api/src/config/parser.rs @@ -5,9 +5,9 @@ use std::io::BufRead; use std::iter::{Iterator, Peekable}; use std::sync::LazyLock; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use regex::Regex; -use serde::de::{value, Deserialize, IntoDeserializer}; +use serde::de::{Deserialize, IntoDeserializer, value}; use super::helper::*; use super::lexer::*; diff --git a/proxmox-network-types/src/ip_address.rs b/proxmox-network-types/src/ip_address.rs index 1c721975..30f1b59b 100644 --- a/proxmox-network-types/src/ip_address.rs +++ b/proxmox-network-types/src/ip_address.rs @@ -17,7 +17,7 @@ pub mod api_types { use std::ops::{Deref, DerefMut}; use proxmox_schema::api_types::IP_V6_SCHEMA; - use proxmox_schema::{api_types::IP_V4_SCHEMA, ApiType, UpdaterType}; + use proxmox_schema::{ApiType, UpdaterType, api_types::IP_V4_SCHEMA}; use serde_with::{DeserializeFromStr, SerializeDisplay}; #[derive( @@ -1620,7 +1620,9 @@ mod tests { assert_eq!( [Ipv6Cidr::new( - [0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF], + [ + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF + ], 128 ) .unwrap(),], @@ -1680,21 +1682,29 @@ mod tests { ) ); - assert!(Ipv4Cidr::new("10.0.0.1".parse::().unwrap(), 32) - .unwrap() - .overlaps(&Ipv4Cidr::new("10.0.0.1".parse::().unwrap(), 32).unwrap())); + assert!( + Ipv4Cidr::new("10.0.0.1".parse::().unwrap(), 32) + .unwrap() + .overlaps(&Ipv4Cidr::new("10.0.0.1".parse::().unwrap(), 32).unwrap()) + ); - assert!(!Ipv4Cidr::new("10.0.0.1".parse::().unwrap(), 32) - .unwrap() - .overlaps(&Ipv4Cidr::new("10.0.0.2".parse::().unwrap(), 32).unwrap())); + assert!( + !Ipv4Cidr::new("10.0.0.1".parse::().unwrap(), 32) + .unwrap() + .overlaps(&Ipv4Cidr::new("10.0.0.2".parse::().unwrap(), 32).unwrap()) + ); - assert!(Ipv4Cidr::new("10.0.0.0".parse::().unwrap(), 8) - .unwrap() - .overlaps(&Ipv4Cidr::new("10.5.10.100".parse::().unwrap(), 32).unwrap())); + assert!( + Ipv4Cidr::new("10.0.0.0".parse::().unwrap(), 8) + .unwrap() + .overlaps(&Ipv4Cidr::new("10.5.10.100".parse::().unwrap(), 32).unwrap()) + ); - assert!(Ipv4Cidr::new("0.0.0.0".parse::().unwrap(), 0) - .unwrap() - .overlaps(&Ipv4Cidr::new("172.16.0.0".parse::().unwrap(), 12).unwrap())); + assert!( + Ipv4Cidr::new("0.0.0.0".parse::().unwrap(), 0) + .unwrap() + .overlaps(&Ipv4Cidr::new("172.16.0.0".parse::().unwrap(), 12).unwrap()) + ); assert!( !Ipv4Cidr::new("192.168.1.0".parse::().unwrap(), 30) @@ -1708,9 +1718,11 @@ mod tests { .overlaps(&Ipv4Cidr::new("192.168.1.2".parse::().unwrap(), 31).unwrap()) ); - assert!(!Ipv4Cidr::new("10.0.0.0".parse::().unwrap(), 8) - .unwrap() - .overlaps(&Ipv4Cidr::new("172.16.0.0".parse::().unwrap(), 12).unwrap())); + assert!( + !Ipv4Cidr::new("10.0.0.0".parse::().unwrap(), 8) + .unwrap() + .overlaps(&Ipv4Cidr::new("172.16.0.0".parse::().unwrap(), 12).unwrap()) + ); assert!( !Ipv4Cidr::new("172.16.0.0".parse::().unwrap(), 12) @@ -1738,9 +1750,11 @@ mod tests { .overlaps(&Ipv4Cidr::new("203.0.113.2".parse::().unwrap(), 31).unwrap()) ); - assert!(Ipv4Cidr::new("0.0.0.0".parse::().unwrap(), 0) - .unwrap() - .overlaps(&Ipv4Cidr::new("0.0.0.0".parse::().unwrap(), 0).unwrap())); + assert!( + Ipv4Cidr::new("0.0.0.0".parse::().unwrap(), 0) + .unwrap() + .overlaps(&Ipv4Cidr::new("0.0.0.0".parse::().unwrap(), 0).unwrap()) + ); assert!( Ipv4Cidr::new("255.255.255.255".parse::().unwrap(), 0) @@ -1804,34 +1818,44 @@ mod tests { .overlaps(&Ipv6Cidr::new("2001:db8::2".parse::().unwrap(), 128).unwrap()) ); - assert!(Ipv6Cidr::new("2001:db8::".parse::().unwrap(), 32) - .unwrap() - .overlaps( - &Ipv6Cidr::new( - "2001:db8:cafe:babe::dead:beef".parse::().unwrap(), - 128 - ) + assert!( + Ipv6Cidr::new("2001:db8::".parse::().unwrap(), 32) .unwrap() - )); - - assert!(Ipv6Cidr::new("::0".parse::().unwrap(), 0) - .unwrap() - .overlaps(&Ipv6Cidr::new("fe80::".parse::().unwrap(), 10).unwrap())); - - assert!(!Ipv6Cidr::new("fe80::".parse::().unwrap(), 10) - .unwrap() - .overlaps(&Ipv6Cidr::new("2001:db8::".parse::().unwrap(), 32).unwrap())); - - assert!(!Ipv6Cidr::new("fc00::".parse::().unwrap(), 7) - .unwrap() - .overlaps(&Ipv6Cidr::new("2001:db8::".parse::().unwrap(), 32).unwrap())); - - assert!(Ipv6Cidr::new("2001:db8::".parse::().unwrap(), 16) - .unwrap() - .overlaps( - &Ipv6Cidr::new("2001:db8:1234:5678::abcd".parse::().unwrap(), 64) + .overlaps( + &Ipv6Cidr::new( + "2001:db8:cafe:babe::dead:beef".parse::().unwrap(), + 128 + ) .unwrap() - )); + ) + ); + + assert!( + Ipv6Cidr::new("::0".parse::().unwrap(), 0) + .unwrap() + .overlaps(&Ipv6Cidr::new("fe80::".parse::().unwrap(), 10).unwrap()) + ); + + assert!( + !Ipv6Cidr::new("fe80::".parse::().unwrap(), 10) + .unwrap() + .overlaps(&Ipv6Cidr::new("2001:db8::".parse::().unwrap(), 32).unwrap()) + ); + + assert!( + !Ipv6Cidr::new("fc00::".parse::().unwrap(), 7) + .unwrap() + .overlaps(&Ipv6Cidr::new("2001:db8::".parse::().unwrap(), 32).unwrap()) + ); + + assert!( + Ipv6Cidr::new("2001:db8::".parse::().unwrap(), 16) + .unwrap() + .overlaps( + &Ipv6Cidr::new("2001:db8:1234:5678::abcd".parse::().unwrap(), 64) + .unwrap() + ) + ); assert!( !Ipv6Cidr::new("2001:db8:0000::".parse::().unwrap(), 48) diff --git a/proxmox-network-types/src/mac_address.rs b/proxmox-network-types/src/mac_address.rs index 4ad82699..abccc1c8 100644 --- a/proxmox-network-types/src/mac_address.rs +++ b/proxmox-network-types/src/mac_address.rs @@ -5,7 +5,7 @@ use serde_with::{DeserializeFromStr, SerializeDisplay}; use thiserror::Error; #[cfg(feature = "api-types")] -use proxmox_schema::{const_regex, ApiStringFormat, ApiType, Schema, StringSchema, UpdaterType}; +use proxmox_schema::{ApiStringFormat, ApiType, Schema, StringSchema, UpdaterType, const_regex}; #[derive(Error, Debug)] pub enum MacAddressError { diff --git a/proxmox-node-status/src/api.rs b/proxmox-node-status/src/api.rs index 4d65d216..de32b5a7 100644 --- a/proxmox-node-status/src/api.rs +++ b/proxmox-node-status/src/api.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use std::process::Command; use std::sync::OnceLock; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use proxmox_schema::api; use proxmox_schema::api_types::NODE_SCHEMA; diff --git a/proxmox-node-status/src/lib.rs b/proxmox-node-status/src/lib.rs index 08a95f9e..cec4ec9f 100644 --- a/proxmox-node-status/src/lib.rs +++ b/proxmox-node-status/src/lib.rs @@ -1,7 +1,7 @@ #[cfg(feature = "api")] mod api; #[cfg(feature = "api")] -pub use crate::api::{init_node_status_api, API_METHOD_GET_STATUS, API_METHOD_REBOOT_OR_SHUTDOWN}; +pub use crate::api::{API_METHOD_GET_STATUS, API_METHOD_REBOOT_OR_SHUTDOWN, init_node_status_api}; mod types; pub use crate::types::{ diff --git a/proxmox-notify/src/api/gotify.rs b/proxmox-notify/src/api/gotify.rs index 27b9c317..5155fd2c 100644 --- a/proxmox-notify/src/api/gotify.rs +++ b/proxmox-notify/src/api/gotify.rs @@ -1,11 +1,11 @@ use proxmox_http_error::HttpError; +use crate::Config; use crate::api::http_err; use crate::endpoints::gotify::{ - DeleteableGotifyProperty, GotifyConfig, GotifyConfigUpdater, GotifyPrivateConfig, - GotifyPrivateConfigUpdater, GOTIFY_TYPENAME, + DeleteableGotifyProperty, GOTIFY_TYPENAME, GotifyConfig, GotifyConfigUpdater, + GotifyPrivateConfig, GotifyPrivateConfigUpdater, }; -use crate::Config; /// Get a list of all gotify endpoints. /// @@ -193,15 +193,17 @@ mod tests { fn test_update_not_existing_returns_error() -> Result<(), HttpError> { let mut config = empty_config(); - assert!(update_endpoint( - &mut config, - "test", - Default::default(), - Default::default(), - None, - None - ) - .is_err()); + assert!( + update_endpoint( + &mut config, + "test", + Default::default(), + Default::default(), + None, + None + ) + .is_err() + ); Ok(()) } @@ -211,15 +213,17 @@ mod tests { let mut config = empty_config(); add_default_gotify_endpoint(&mut config)?; - assert!(update_endpoint( - &mut config, - "gotify-endpoint", - Default::default(), - Default::default(), - None, - Some(&[0; 32]) - ) - .is_err()); + assert!( + update_endpoint( + &mut config, + "gotify-endpoint", + Default::default(), + Default::default(), + None, + Some(&[0; 32]) + ) + .is_err() + ); Ok(()) } diff --git a/proxmox-notify/src/api/matcher.rs b/proxmox-notify/src/api/matcher.rs index f5605acb..b2bf15ae 100644 --- a/proxmox-notify/src/api/matcher.rs +++ b/proxmox-notify/src/api/matcher.rs @@ -1,10 +1,10 @@ use proxmox_http_error::HttpError; +use crate::Config; use crate::api::http_err; use crate::matcher::{ - DeleteableMatcherProperty, MatcherConfig, MatcherConfigUpdater, MATCHER_TYPENAME, + DeleteableMatcherProperty, MATCHER_TYPENAME, MatcherConfig, MatcherConfigUpdater, }; -use crate::Config; /// Get a list of all matchers /// @@ -182,14 +182,16 @@ matcher: matcher2 #[test] fn test_update_invalid_digest_returns_error() -> Result<(), HttpError> { let mut config = config_with_two_matchers(); - assert!(update_matcher( - &mut config, - "matcher1", - Default::default(), - None, - Some(&[0u8; 32]) - ) - .is_err()); + assert!( + update_matcher( + &mut config, + "matcher1", + Default::default(), + None, + Some(&[0u8; 32]) + ) + .is_err() + ); Ok(()) } diff --git a/proxmox-notify/src/api/sendmail.rs b/proxmox-notify/src/api/sendmail.rs index e0adb64b..eaafd001 100644 --- a/proxmox-notify/src/api/sendmail.rs +++ b/proxmox-notify/src/api/sendmail.rs @@ -1,10 +1,10 @@ use proxmox_http_error::HttpError; +use crate::Config; use crate::api::{http_bail, http_err}; use crate::endpoints::sendmail::{ - DeleteableSendmailProperty, SendmailConfig, SendmailConfigUpdater, SENDMAIL_TYPENAME, + DeleteableSendmailProperty, SENDMAIL_TYPENAME, SendmailConfig, SendmailConfigUpdater, }; -use crate::Config; /// Get a list of all sendmail endpoints. /// @@ -203,21 +203,23 @@ pub mod tests { let mut config = empty_config(); add_sendmail_endpoint_for_test(&mut config, "sendmail-endpoint")?; - assert!(update_endpoint( - &mut config, - "sendmail-endpoint", - SendmailConfigUpdater { - mailto: Some(vec!["user2@example.com".into(), "user3@example.com".into()]), - mailto_user: None, - from_address: Some("root@example.com".into()), - author: Some("newauthor".into()), - comment: Some("new comment".into()), - ..Default::default() - }, - None, - Some(&[0; 32]), - ) - .is_err()); + assert!( + update_endpoint( + &mut config, + "sendmail-endpoint", + SendmailConfigUpdater { + mailto: Some(vec!["user2@example.com".into(), "user3@example.com".into()]), + mailto_user: None, + from_address: Some("root@example.com".into()), + author: Some("newauthor".into()), + comment: Some("new comment".into()), + ..Default::default() + }, + None, + Some(&[0; 32]), + ) + .is_err() + ); Ok(()) } diff --git a/proxmox-notify/src/api/smtp.rs b/proxmox-notify/src/api/smtp.rs index 470701bf..41a94581 100644 --- a/proxmox-notify/src/api/smtp.rs +++ b/proxmox-notify/src/api/smtp.rs @@ -1,11 +1,11 @@ use proxmox_http_error::HttpError; +use crate::Config; use crate::api::{http_bail, http_err}; use crate::endpoints::smtp::{ - DeleteableSmtpProperty, SmtpConfig, SmtpConfigUpdater, SmtpPrivateConfig, - SmtpPrivateConfigUpdater, SMTP_TYPENAME, + DeleteableSmtpProperty, SMTP_TYPENAME, SmtpConfig, SmtpConfigUpdater, SmtpPrivateConfig, + SmtpPrivateConfigUpdater, }; -use crate::Config; /// Get a list of all smtp endpoints. /// @@ -249,15 +249,17 @@ pub mod tests { fn test_update_not_existing_returns_error() -> Result<(), HttpError> { let mut config = empty_config(); - assert!(update_endpoint( - &mut config, - "test", - Default::default(), - Default::default(), - None, - None, - ) - .is_err()); + assert!( + update_endpoint( + &mut config, + "test", + Default::default(), + Default::default(), + None, + None, + ) + .is_err() + ); Ok(()) } @@ -267,15 +269,17 @@ pub mod tests { let mut config = empty_config(); add_smtp_endpoint_for_test(&mut config, "sendmail-endpoint")?; - assert!(update_endpoint( - &mut config, - "sendmail-endpoint", - Default::default(), - Default::default(), - None, - Some(&[0; 32]), - ) - .is_err()); + assert!( + update_endpoint( + &mut config, + "sendmail-endpoint", + Default::default(), + Default::default(), + None, + Some(&[0; 32]), + ) + .is_err() + ); Ok(()) } diff --git a/proxmox-notify/src/api/webhook.rs b/proxmox-notify/src/api/webhook.rs index 9d904d0b..1d29dcc8 100644 --- a/proxmox-notify/src/api/webhook.rs +++ b/proxmox-notify/src/api/webhook.rs @@ -7,10 +7,10 @@ use proxmox_schema::property_string::PropertyString; use crate::api::http_err; use crate::endpoints::webhook::{ - DeleteableWebhookProperty, KeyAndBase64Val, WebhookConfig, WebhookConfigUpdater, - WebhookPrivateConfig, WEBHOOK_TYPENAME, + DeleteableWebhookProperty, KeyAndBase64Val, WEBHOOK_TYPENAME, WebhookConfig, + WebhookConfigUpdater, WebhookPrivateConfig, }; -use crate::{http_bail, Config}; +use crate::{Config, http_bail}; use super::remove_private_config_entry; use super::set_private_config_entry; @@ -301,11 +301,10 @@ mod tests { name: "webhook-endpoint".into(), method: HttpMethod::Post, url: "http://example.com/webhook".into(), - header: vec![KeyAndBase64Val::new_with_plain_value( - "Content-Type", - "application/json", - ) - .into()], + header: vec![ + KeyAndBase64Val::new_with_plain_value("Content-Type", "application/json") + .into(), + ], body: Some(proxmox_base64::encode("this is the body")), comment: Some("comment".into()), disable: Some(false), @@ -332,14 +331,16 @@ mod tests { let mut config = empty_config(); add_default_webhook_endpoint(&mut config)?; - assert!(update_endpoint( - &mut config, - "webhook-endpoint", - Default::default(), - None, - Some(&[0; 32]) - ) - .is_err()); + assert!( + update_endpoint( + &mut config, + "webhook-endpoint", + Default::default(), + None, + Some(&[0; 32]) + ) + .is_err() + ); Ok(()) } diff --git a/proxmox-notify/src/config.rs b/proxmox-notify/src/config.rs index ec28c22c..952e7726 100644 --- a/proxmox-notify/src/config.rs +++ b/proxmox-notify/src/config.rs @@ -3,9 +3,9 @@ use std::sync::OnceLock; use proxmox_schema::{ApiType, ObjectSchema}; use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin}; -use crate::matcher::{MatcherConfig, MATCHER_TYPENAME}; -use crate::schema::BACKEND_NAME_SCHEMA; use crate::Error; +use crate::matcher::{MATCHER_TYPENAME, MatcherConfig}; +use crate::schema::BACKEND_NAME_SCHEMA; /// Section config schema for the public config file. pub fn config_parser() -> &'static SectionConfig { @@ -24,7 +24,7 @@ fn config_init() -> SectionConfig { #[cfg(feature = "sendmail")] { - use crate::endpoints::sendmail::{SendmailConfig, SENDMAIL_TYPENAME}; + use crate::endpoints::sendmail::{SENDMAIL_TYPENAME, SendmailConfig}; const SENDMAIL_SCHEMA: &ObjectSchema = SendmailConfig::API_SCHEMA.unwrap_object_schema(); config.register_plugin(SectionConfigPlugin::new( @@ -35,7 +35,7 @@ fn config_init() -> SectionConfig { } #[cfg(feature = "smtp")] { - use crate::endpoints::smtp::{SmtpConfig, SMTP_TYPENAME}; + use crate::endpoints::smtp::{SMTP_TYPENAME, SmtpConfig}; const SMTP_SCHEMA: &ObjectSchema = SmtpConfig::API_SCHEMA.unwrap_object_schema(); config.register_plugin(SectionConfigPlugin::new( @@ -46,7 +46,7 @@ fn config_init() -> SectionConfig { } #[cfg(feature = "gotify")] { - use crate::endpoints::gotify::{GotifyConfig, GOTIFY_TYPENAME}; + use crate::endpoints::gotify::{GOTIFY_TYPENAME, GotifyConfig}; const GOTIFY_SCHEMA: &ObjectSchema = GotifyConfig::API_SCHEMA.unwrap_object_schema(); config.register_plugin(SectionConfigPlugin::new( @@ -57,7 +57,7 @@ fn config_init() -> SectionConfig { } #[cfg(feature = "webhook")] { - use crate::endpoints::webhook::{WebhookConfig, WEBHOOK_TYPENAME}; + use crate::endpoints::webhook::{WEBHOOK_TYPENAME, WebhookConfig}; const WEBHOOK_SCHEMA: &ObjectSchema = WebhookConfig::API_SCHEMA.unwrap_object_schema(); config.register_plugin(SectionConfigPlugin::new( @@ -83,7 +83,7 @@ fn private_config_init() -> SectionConfig { #[cfg(feature = "gotify")] { - use crate::endpoints::gotify::{GotifyPrivateConfig, GOTIFY_TYPENAME}; + use crate::endpoints::gotify::{GOTIFY_TYPENAME, GotifyPrivateConfig}; const GOTIFY_SCHEMA: &ObjectSchema = GotifyPrivateConfig::API_SCHEMA.unwrap_object_schema(); config.register_plugin(SectionConfigPlugin::new( @@ -95,7 +95,7 @@ fn private_config_init() -> SectionConfig { #[cfg(feature = "smtp")] { - use crate::endpoints::smtp::{SmtpPrivateConfig, SMTP_TYPENAME}; + use crate::endpoints::smtp::{SMTP_TYPENAME, SmtpPrivateConfig}; const SMTP_SCHEMA: &ObjectSchema = SmtpPrivateConfig::API_SCHEMA.unwrap_object_schema(); config.register_plugin(SectionConfigPlugin::new( @@ -107,7 +107,7 @@ fn private_config_init() -> SectionConfig { #[cfg(feature = "webhook")] { - use crate::endpoints::webhook::{WebhookPrivateConfig, WEBHOOK_TYPENAME}; + use crate::endpoints::webhook::{WEBHOOK_TYPENAME, WebhookPrivateConfig}; const WEBHOOK_SCHEMA: &ObjectSchema = WebhookPrivateConfig::API_SCHEMA.unwrap_object_schema(); diff --git a/proxmox-notify/src/context/mod.rs b/proxmox-notify/src/context/mod.rs index 8b6e2c43..87a2a716 100644 --- a/proxmox-notify/src/context/mod.rs +++ b/proxmox-notify/src/context/mod.rs @@ -1,8 +1,8 @@ use std::fmt::Debug; use std::sync::Mutex; -use crate::renderer::TemplateSource; use crate::Error; +use crate::renderer::TemplateSource; #[cfg(any(feature = "pve-context", feature = "pbs-context"))] pub mod common; diff --git a/proxmox-notify/src/context/pbs.rs b/proxmox-notify/src/context/pbs.rs index 3e5da59c..a9121548 100644 --- a/proxmox-notify/src/context/pbs.rs +++ b/proxmox-notify/src/context/pbs.rs @@ -6,9 +6,9 @@ use tracing::error; use proxmox_schema::{ObjectSchema, Schema, StringSchema}; use proxmox_section_config::{SectionConfig, SectionConfigPlugin}; -use crate::context::{common, Context}; -use crate::renderer::TemplateSource; use crate::Error; +use crate::context::{Context, common}; +use crate::renderer::TemplateSource; const PBS_USER_CFG_FILENAME: &str = "/etc/proxmox-backup/user.cfg"; const PBS_NODE_CFG_FILENAME: &str = "/etc/proxmox-backup/node.cfg"; diff --git a/proxmox-notify/src/context/pve.rs b/proxmox-notify/src/context/pve.rs index a97cce26..3d9ff92e 100644 --- a/proxmox-notify/src/context/pve.rs +++ b/proxmox-notify/src/context/pve.rs @@ -1,6 +1,6 @@ -use crate::context::{common, Context}; -use crate::renderer::TemplateSource; use crate::Error; +use crate::context::{Context, common}; +use crate::renderer::TemplateSource; use std::path::Path; fn lookup_mail_address(content: &str, user: &str) -> Option { diff --git a/proxmox-notify/src/context/test.rs b/proxmox-notify/src/context/test.rs index 2c236b4c..22da38d3 100644 --- a/proxmox-notify/src/context/test.rs +++ b/proxmox-notify/src/context/test.rs @@ -1,6 +1,6 @@ +use crate::Error; use crate::context::Context; use crate::renderer::TemplateSource; -use crate::Error; #[derive(Debug)] pub struct TestContext; diff --git a/proxmox-notify/src/endpoints/gotify.rs b/proxmox-notify/src/endpoints/gotify.rs index 3e12a60e..7d0f5cdc 100644 --- a/proxmox-notify/src/endpoints/gotify.rs +++ b/proxmox-notify/src/endpoints/gotify.rs @@ -7,12 +7,12 @@ use serde_json::json; use proxmox_http::client::sync::Client; use proxmox_http::{HttpClient, HttpOptions, ProxyConfig}; use proxmox_schema::api_types::COMMENT_SCHEMA; -use proxmox_schema::{api, Updater}; +use proxmox_schema::{Updater, api}; use crate::context::context; use crate::renderer::TemplateType; use crate::schema::ENTITY_NAME_SCHEMA; -use crate::{renderer, Content, Endpoint, Error, Notification, Origin, Severity}; +use crate::{Content, Endpoint, Error, Notification, Origin, Severity, renderer}; const HTTP_TIMEOUT: Duration = Duration::from_secs(10); diff --git a/proxmox-notify/src/endpoints/sendmail.rs b/proxmox-notify/src/endpoints/sendmail.rs index 70b0f111..4f26a121 100644 --- a/proxmox-notify/src/endpoints/sendmail.rs +++ b/proxmox-notify/src/endpoints/sendmail.rs @@ -2,13 +2,13 @@ use proxmox_sendmail::Mail; use serde::{Deserialize, Serialize}; use proxmox_schema::api_types::COMMENT_SCHEMA; -use proxmox_schema::{api, Updater}; +use proxmox_schema::{Updater, api}; use crate::context; use crate::endpoints::common::mail; use crate::renderer::TemplateType; use crate::schema::{EMAIL_SCHEMA, ENTITY_NAME_SCHEMA, USER_SCHEMA}; -use crate::{renderer, Content, Endpoint, Error, Notification, Origin}; +use crate::{Content, Endpoint, Error, Notification, Origin, renderer}; pub(crate) const SENDMAIL_TYPENAME: &str = "sendmail"; diff --git a/proxmox-notify/src/endpoints/smtp.rs b/proxmox-notify/src/endpoints/smtp.rs index 6785932f..85988aa7 100644 --- a/proxmox-notify/src/endpoints/smtp.rs +++ b/proxmox-notify/src/endpoints/smtp.rs @@ -4,17 +4,17 @@ use std::time::Duration; use lettre::message::header::{HeaderName, HeaderValue}; use lettre::message::{Mailbox, MultiPart, SinglePart}; use lettre::transport::smtp::client::{Tls, TlsParameters}; -use lettre::{message::header::ContentType, Message, SmtpTransport, Transport}; +use lettre::{Message, SmtpTransport, Transport, message::header::ContentType}; use serde::{Deserialize, Serialize}; use proxmox_schema::api_types::COMMENT_SCHEMA; -use proxmox_schema::{api, Updater}; +use proxmox_schema::{Updater, api}; use crate::context::context; use crate::endpoints::common::mail; use crate::renderer::TemplateType; use crate::schema::{EMAIL_SCHEMA, ENTITY_NAME_SCHEMA, USER_SCHEMA}; -use crate::{renderer, Content, Endpoint, Error, Notification, Origin}; +use crate::{Content, Endpoint, Error, Notification, Origin, renderer}; pub(crate) const SMTP_TYPENAME: &str = "smtp"; @@ -292,8 +292,8 @@ fn build_forwarded_message( endpoint_name: &str, raw: &[u8], ) -> Result { - use lettre::message::header::ContentTransferEncoding; use lettre::message::Body; + use lettre::message::header::ContentTransferEncoding; use tracing::error; let parsed_message = mail_parser::MessageParser::default() diff --git a/proxmox-notify/src/endpoints/webhook.rs b/proxmox-notify/src/endpoints/webhook.rs index 0167efcf..f0fd5b6a 100644 --- a/proxmox-notify/src/endpoints/webhook.rs +++ b/proxmox-notify/src/endpoints/webhook.rs @@ -17,17 +17,17 @@ use http::Request; use percent_encoding::AsciiSet; use proxmox_schema::property_string::PropertyString; use serde::{Deserialize, Serialize}; -use serde_json::{json, Map, Value}; +use serde_json::{Map, Value, json}; use proxmox_http::client::sync::Client; use proxmox_http::{HttpClient, HttpOptions, ProxyConfig}; use proxmox_schema::api_types::{COMMENT_SCHEMA, HTTP_URL_SCHEMA}; -use proxmox_schema::{api, ApiStringFormat, ApiType, Schema, StringSchema, Updater}; +use proxmox_schema::{ApiStringFormat, ApiType, Schema, StringSchema, Updater, api}; use crate::context::context; use crate::renderer::TemplateType; use crate::schema::ENTITY_NAME_SCHEMA; -use crate::{renderer, Content, Endpoint, Error, Notification, Origin}; +use crate::{Content, Endpoint, Error, Notification, Origin, renderer}; /// This will be used as a section type in the public/private configuration file. pub(crate) const WEBHOOK_TYPENAME: &str = "webhook"; diff --git a/proxmox-notify/src/lib.rs b/proxmox-notify/src/lib.rs index 879f8326..12d21edc 100644 --- a/proxmox-notify/src/lib.rs +++ b/proxmox-notify/src/lib.rs @@ -7,8 +7,8 @@ use std::str::FromStr; use context::context; use serde::{Deserialize, Serialize}; -use serde_json::json; use serde_json::Value; +use serde_json::json; use tracing::{error, info}; use proxmox_schema::api; @@ -16,7 +16,7 @@ use proxmox_section_config::SectionConfigData; use proxmox_uuid::Uuid; pub mod matcher; -use matcher::{MatcherConfig, MATCHER_TYPENAME}; +use matcher::{MATCHER_TYPENAME, MatcherConfig}; pub mod api; pub mod config; diff --git a/proxmox-notify/src/matcher.rs b/proxmox-notify/src/matcher.rs index 083c2dbd..9964e4bf 100644 --- a/proxmox-notify/src/matcher.rs +++ b/proxmox-notify/src/matcher.rs @@ -9,8 +9,8 @@ use serde::{Deserialize, Serialize}; use tracing::{error, info}; use proxmox_schema::api_types::{COMMENT_SCHEMA, SAFE_ID_REGEX_STR}; -use proxmox_schema::{api, const_regex, ApiStringFormat, Schema, StringSchema, Updater}; -use proxmox_time::{parse_daily_duration, DailyDuration}; +use proxmox_schema::{ApiStringFormat, Schema, StringSchema, Updater, api, const_regex}; +use proxmox_time::{DailyDuration, parse_daily_duration}; use crate::schema::ENTITY_NAME_SCHEMA; use crate::{Error, Notification, Origin, Severity}; diff --git a/proxmox-notify/src/renderer/mod.rs b/proxmox-notify/src/renderer/mod.rs index 17c56bc8..a0b7df7b 100644 --- a/proxmox-notify/src/renderer/mod.rs +++ b/proxmox-notify/src/renderer/mod.rs @@ -12,7 +12,7 @@ use tracing::error; use proxmox_human_byte::HumanByte; use proxmox_time::TimeSpan; -use crate::{context, Error}; +use crate::{Error, context}; mod html; mod plaintext; diff --git a/proxmox-oci/src/lib.rs b/proxmox-oci/src/lib.rs index 3b92d849..3022f2d7 100644 --- a/proxmox-oci/src/lib.rs +++ b/proxmox-oci/src/lib.rs @@ -1,13 +1,13 @@ use std::collections::HashMap; -use std::fs::{read_dir, remove_dir_all, remove_file, File}; +use std::fs::{File, read_dir, remove_dir_all, remove_file}; use std::io::{Read, Seek, SeekFrom}; use std::path::{Path, PathBuf}; use std::str::FromStr; use flate2::read::GzDecoder; +use oci_spec::OciSpecError; pub use oci_spec::image::{Arch, Config}; use oci_spec::image::{ImageConfiguration, ImageManifest, MediaType}; -use oci_spec::OciSpecError; use sha2::digest::generic_array::GenericArray; use sha2::{Digest, Sha256}; use tar::{Archive, EntryType}; diff --git a/proxmox-oci/src/oci_tar_image.rs b/proxmox-oci/src/oci_tar_image.rs index 23e1bfe0..79d44706 100644 --- a/proxmox-oci/src/oci_tar_image.rs +++ b/proxmox-oci/src/oci_tar_image.rs @@ -3,8 +3,8 @@ use std::io::{Read, Seek, SeekFrom}; use std::ops::Range; use std::path::{Path, PathBuf}; -use oci_spec::image::{Arch, Digest, ImageIndex, ImageManifest, MediaType}; use oci_spec::OciSpecError; +use oci_spec::image::{Arch, Digest, ImageIndex, ImageManifest, MediaType}; use tar::Archive; use proxmox_io::RangeReader; diff --git a/proxmox-oci/tests/extract_replace.rs b/proxmox-oci/tests/extract_replace.rs index eb41f9e3..54eddff4 100644 --- a/proxmox-oci/tests/extract_replace.rs +++ b/proxmox-oci/tests/extract_replace.rs @@ -1,6 +1,6 @@ use std::fs::{read_to_string, remove_dir_all}; -use proxmox_oci::{parse_and_extract_image, Arch}; +use proxmox_oci::{Arch, parse_and_extract_image}; use proxmox_sys::fs::make_tmp_dir; #[test] diff --git a/proxmox-oci/tests/extract_whiteouts.rs b/proxmox-oci/tests/extract_whiteouts.rs index 71ec4dea..77328ba0 100644 --- a/proxmox-oci/tests/extract_whiteouts.rs +++ b/proxmox-oci/tests/extract_whiteouts.rs @@ -1,6 +1,6 @@ use std::fs::remove_dir_all; -use proxmox_oci::{parse_and_extract_image, Arch}; +use proxmox_oci::{Arch, parse_and_extract_image}; use proxmox_sys::fs::make_tmp_dir; #[test] diff --git a/proxmox-openid/src/auth_state.rs b/proxmox-openid/src/auth_state.rs index 80cde12f..b19e83fe 100644 --- a/proxmox-openid/src/auth_state.rs +++ b/proxmox-openid/src/auth_state.rs @@ -1,9 +1,9 @@ use std::path::{Path, PathBuf}; -use anyhow::{bail, Error}; -use serde_json::{json, Value}; +use anyhow::{Error, bail}; +use serde_json::{Value, json}; -use proxmox_sys::fs::{file_get_json, open_file_locked, replace_file, CreateOptions}; +use proxmox_sys::fs::{CreateOptions, file_get_json, open_file_locked, replace_file}; use proxmox_time::epoch_i64; use super::{PrivateAuthState, PublicAuthState}; diff --git a/proxmox-openid/src/lib.rs b/proxmox-openid/src/lib.rs index 0388a8fa..46f4ad65 100644 --- a/proxmox-openid/src/lib.rs +++ b/proxmox-openid/src/lib.rs @@ -2,7 +2,7 @@ use std::path::Path; -use anyhow::{format_err, Error}; +use anyhow::{Error, format_err}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -13,13 +13,6 @@ mod auth_state; pub use auth_state::*; use openidconnect::{ - //curl::http_client, - core::{ - CoreAuthDisplay, CoreAuthPrompt, CoreAuthenticationFlow, CoreErrorResponseType, - CoreGenderClaim, CoreIdTokenVerifier, CoreJsonWebKey, CoreJweContentEncryptionAlgorithm, - CoreJwsSigningAlgorithm, CoreProviderMetadata, CoreRevocableToken, - CoreRevocationErrorResponse, CoreTokenIntrospectionResponse, CoreTokenType, - }, AdditionalClaims, AuthenticationContextClass, AuthorizationCode, @@ -43,6 +36,13 @@ use openidconnect::{ StandardErrorResponse, StandardTokenResponse, UserInfoClaims, + //curl::http_client, + core::{ + CoreAuthDisplay, CoreAuthPrompt, CoreAuthenticationFlow, CoreErrorResponseType, + CoreGenderClaim, CoreIdTokenVerifier, CoreJsonWebKey, CoreJweContentEncryptionAlgorithm, + CoreJwsSigningAlgorithm, CoreProviderMetadata, CoreRevocableToken, + CoreRevocationErrorResponse, CoreTokenIntrospectionResponse, CoreTokenType, + }, }; /// Stores Additional Claims into a serde_json::Value; diff --git a/proxmox-rate-limiter/src/rate_limiter.rs b/proxmox-rate-limiter/src/rate_limiter.rs index 8d879757..26267a4b 100644 --- a/proxmox-rate-limiter/src/rate_limiter.rs +++ b/proxmox-rate-limiter/src/rate_limiter.rs @@ -1,7 +1,7 @@ use std::convert::TryInto; use std::time::{Duration, Instant}; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; /// Rate limiter interface. pub trait RateLimit { diff --git a/proxmox-rate-limiter/src/shared_rate_limiter.rs b/proxmox-rate-limiter/src/shared_rate_limiter.rs index 2822e7ea..3b656b6a 100644 --- a/proxmox-rate-limiter/src/shared_rate_limiter.rs +++ b/proxmox-rate-limiter/src/shared_rate_limiter.rs @@ -4,13 +4,13 @@ use std::mem::MaybeUninit; use std::path::Path; use std::time::{Duration, Instant}; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use nix::sys::stat::Mode; use nix::unistd::User; -use proxmox_shared_memory::{check_subtype, initialize_subtype}; use proxmox_shared_memory::{Init, SharedMemory, SharedMutex}; -use proxmox_sys::fs::{create_path, CreateOptions}; +use proxmox_shared_memory::{check_subtype, initialize_subtype}; +use proxmox_sys::fs::{CreateOptions, create_path}; use crate::{RateLimit, RateLimiter, ShareableRateLimit}; diff --git a/proxmox-resource-scheduling/src/pve_static.rs b/proxmox-resource-scheduling/src/pve_static.rs index b81086dd..7c60cc61 100644 --- a/proxmox-resource-scheduling/src/pve_static.rs +++ b/proxmox-resource-scheduling/src/pve_static.rs @@ -36,11 +36,7 @@ impl AsRef for StaticNodeUsage { /// Calculate new CPU usage in percent. /// `add` being `0.0` means "unlimited" and results in `max` being added. fn add_cpu_usage(old: f64, max: f64, add: f64) -> f64 { - if add == 0.0 { - old + max - } else { - old + add - } + if add == 0.0 { old + max } else { old + add } } #[derive(Serialize, Deserialize)] diff --git a/proxmox-resource-scheduling/src/topsis.rs b/proxmox-resource-scheduling/src/topsis.rs index 6d078aa6..c2967f0f 100644 --- a/proxmox-resource-scheduling/src/topsis.rs +++ b/proxmox-resource-scheduling/src/topsis.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; fn differences(xs: &[f64; N], ys: &[f64; N]) -> [f64; N] { // Uses SSE optimizations diff --git a/proxmox-resource-scheduling/tests/topsis.rs b/proxmox-resource-scheduling/tests/topsis.rs index 601522f0..5be6665b 100644 --- a/proxmox-resource-scheduling/tests/topsis.rs +++ b/proxmox-resource-scheduling/tests/topsis.rs @@ -1,6 +1,6 @@ use anyhow::Error; -use proxmox_resource_scheduling::topsis::{rank_alternatives, Criteria, Criterion, Matrix}; +use proxmox_resource_scheduling::topsis::{Criteria, Criterion, Matrix, rank_alternatives}; #[test] fn test_topsis_single_criterion() -> Result<(), Error> { diff --git a/proxmox-rest-server/examples/minimal-rest-server.rs b/proxmox-rest-server/examples/minimal-rest-server.rs index 61376288..f0078d68 100644 --- a/proxmox-rest-server/examples/minimal-rest-server.rs +++ b/proxmox-rest-server/examples/minimal-rest-server.rs @@ -3,10 +3,10 @@ use std::future::Future; use std::pin::Pin; use std::sync::{LazyLock, Mutex}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use futures::future; -use http::request::Parts; use http::HeaderMap; +use http::request::Parts; use hyper::{Method, Response}; use hyper_util::server::graceful::GracefulShutdown; use tokio::net::TcpListener; @@ -14,7 +14,7 @@ use tokio::net::TcpListener; use proxmox_http::Body; use proxmox_log::LevelFilter; use proxmox_router::{ - list_subdirs_api_method, Router, RpcEnvironmentType, SubdirMap, UserInformation, + Router, RpcEnvironmentType, SubdirMap, UserInformation, list_subdirs_api_method, }; use proxmox_schema::api; diff --git a/proxmox-rest-server/src/api_config.rs b/proxmox-rest-server/src/api_config.rs index 87d6566c..3c768d6e 100644 --- a/proxmox-rest-server/src/api_config.rs +++ b/proxmox-rest-server/src/api_config.rs @@ -6,10 +6,10 @@ use std::pin::Pin; use std::sync::{Arc, Mutex}; use std::task::{Context, Poll}; -use anyhow::{format_err, Error}; +use anyhow::{Error, format_err}; use http::{HeaderMap, Method, Uri}; -use hyper::http::request::Parts; use hyper::Response; +use hyper::http::request::Parts; use hyper_util::rt::TokioIo; use tower_service::Service; @@ -17,10 +17,10 @@ use proxmox_daemon::command_socket::CommandSocket; use proxmox_http::Body; use proxmox_log::{FileLogOptions, FileLogger}; use proxmox_router::{Router, RpcEnvironmentType, UserInformation}; -use proxmox_sys::fs::{create_path, CreateOptions}; +use proxmox_sys::fs::{CreateOptions, create_path}; -use crate::rest::Handler; use crate::RestEnvironment; +use crate::rest::Handler; /// REST server configuration pub struct ApiConfig { @@ -335,7 +335,7 @@ mod templates { use std::sync::RwLock; use std::time::SystemTime; - use anyhow::{bail, format_err, Error}; + use anyhow::{Error, bail, format_err}; use handlebars::Handlebars; use serde::Serialize; diff --git a/proxmox-rest-server/src/compression.rs b/proxmox-rest-server/src/compression.rs index 189d7041..f8d25e34 100644 --- a/proxmox-rest-server/src/compression.rs +++ b/proxmox-rest-server/src/compression.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use hyper::header; /// Possible Compression Methods, order determines preference (later is preferred) diff --git a/proxmox-rest-server/src/connection.rs b/proxmox-rest-server/src/connection.rs index 1faa3828..573cba52 100644 --- a/proxmox-rest-server/src/connection.rs +++ b/proxmox-rest-server/src/connection.rs @@ -7,11 +7,11 @@ use std::mem::ManuallyDrop; use std::net::SocketAddr; use std::os::unix::io::AsFd; use std::path::PathBuf; -use std::pin::{pin, Pin}; +use std::pin::{Pin, pin}; use std::sync::{Arc, Mutex}; use std::time::Duration; -use anyhow::{format_err, Context, Error}; +use anyhow::{Context, Error, format_err}; use futures::FutureExt; use openssl::ec::{EcGroup, EcKey}; use openssl::nid::Nid; diff --git a/proxmox-rest-server/src/environment.rs b/proxmox-rest-server/src/environment.rs index c349c324..47ff5a4f 100644 --- a/proxmox-rest-server/src/environment.rs +++ b/proxmox-rest-server/src/environment.rs @@ -1,7 +1,7 @@ use std::net::SocketAddr; use std::sync::Arc; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use proxmox_router::{RpcEnvironment, RpcEnvironmentType}; diff --git a/proxmox-rest-server/src/formatter.rs b/proxmox-rest-server/src/formatter.rs index 9ce87205..7d098e83 100644 --- a/proxmox-rest-server/src/formatter.rs +++ b/proxmox-rest-server/src/formatter.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use anyhow::Error; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use hyper::header; use hyper::{Response, StatusCode}; diff --git a/proxmox-rest-server/src/h2service.rs b/proxmox-rest-server/src/h2service.rs index 09843477..b5edc703 100644 --- a/proxmox-rest-server/src/h2service.rs +++ b/proxmox-rest-server/src/h2service.rs @@ -14,7 +14,7 @@ use proxmox_router::http_err; use proxmox_router::{ApiResponseFuture, HttpError, Router, RpcEnvironment}; use crate::formatter::*; -use crate::{normalize_path_with_components, WorkerTask}; +use crate::{WorkerTask, normalize_path_with_components}; /// Hyper Service implementation to handle stateful H2 connections. /// diff --git a/proxmox-rest-server/src/lib.rs b/proxmox-rest-server/src/lib.rs index 5ddd3667..2ab729a6 100644 --- a/proxmox-rest-server/src/lib.rs +++ b/proxmox-rest-server/src/lib.rs @@ -19,7 +19,7 @@ use std::fmt; use std::sync::LazyLock; -use anyhow::{format_err, Error}; +use anyhow::{Error, format_err}; use nix::unistd::Pid; use proxmox_sys::fs::CreateOptions; diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs index 96ea406b..6a934e4b 100644 --- a/proxmox-rest-server/src/rest.rs +++ b/proxmox-rest-server/src/rest.rs @@ -7,7 +7,7 @@ use std::pin::Pin; use std::sync::{Arc, LazyLock, Mutex}; use std::task::{Context, Poll}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use futures::future::FutureExt; use futures::stream::TryStreamExt; use http_body_util::{BodyDataStream, BodyStream}; @@ -34,8 +34,8 @@ use proxmox_http::{RateLimiterTag, RateLimiterTagsHandle}; #[cfg(not(feature = "rate-limited-stream"))] type RateLimiterTagsHandle = (); use proxmox_router::{ - check_api_permission, ApiHandler, ApiMethod, HttpError, Permission, RpcEnvironment, - RpcEnvironmentType, UserInformation, + ApiHandler, ApiMethod, HttpError, Permission, RpcEnvironment, RpcEnvironmentType, + UserInformation, check_api_permission, }; use proxmox_router::{http_bail, http_err}; use proxmox_schema::{ObjectSchemaType, ParameterSchema}; @@ -45,7 +45,7 @@ use proxmox_compression::DeflateEncoder; use proxmox_log::FileLogger; use crate::{ - formatter::*, normalize_path, ApiConfig, AuthError, CompressionMethod, RestEnvironment, + ApiConfig, AuthError, CompressionMethod, RestEnvironment, formatter::*, normalize_path, }; unsafe extern "C" { diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs index 84965f25..913d20a3 100644 --- a/proxmox-rest-server/src/worker_task.rs +++ b/proxmox-rest-server/src/worker_task.rs @@ -7,11 +7,11 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::{Arc, LazyLock, Mutex, OnceLock}; use std::time::{Duration, SystemTime}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use futures::*; use nix::fcntl::OFlag; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use tokio::signal::unix::SignalKind; use tokio::sync::{oneshot, watch}; use tracing::{error, info, warn}; @@ -20,7 +20,7 @@ use proxmox_daemon::command_socket::CommandSocket; use proxmox_lang::try_block; use proxmox_log::{FileLogOptions, FileLogger, LogContext}; use proxmox_schema::upid::UPID; -use proxmox_sys::fs::{atomic_open_or_create_file, create_path, replace_file, CreateOptions}; +use proxmox_sys::fs::{CreateOptions, atomic_open_or_create_file, create_path, replace_file}; use proxmox_sys::linux::procfs; use proxmox_sys::logrotate::{LogRotate, LogRotateFiles}; use proxmox_worker_task::WorkerTaskContext; diff --git a/proxmox-rest-server/tests/worker_task.rs b/proxmox-rest-server/tests/worker_task.rs index c2afc463..5189a7e0 100644 --- a/proxmox-rest-server/tests/worker_task.rs +++ b/proxmox-rest-server/tests/worker_task.rs @@ -1,9 +1,9 @@ use std::fs::{remove_dir_all, write}; use proxmox_rest_server::{ - init_worker_tasks, upid_log_path, upid_read_status, TaskState, WorkerTask, + TaskState, WorkerTask, init_worker_tasks, upid_log_path, upid_read_status, }; -use proxmox_sys::fs::{make_tmp_dir, CreateOptions}; +use proxmox_sys::fs::{CreateOptions, make_tmp_dir}; fn upid_read_status_test_helper(log: &str, expected: &TaskState) { let task = WorkerTask::new("x", None, "u@pam".into(), false).unwrap().0; diff --git a/proxmox-router/src/cli/command.rs b/proxmox-router/src/cli/command.rs index 3389dc50..060f0052 100644 --- a/proxmox-router/src/cli/command.rs +++ b/proxmox-router/src/cli/command.rs @@ -1,7 +1,7 @@ use std::cell::RefCell; use std::sync::Arc; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -11,8 +11,8 @@ use proxmox_schema::*; use super::environment::CliEnvironment; use super::getopts; use super::{ - generate_nested_usage, generate_usage_str_do, print_help, print_nested_usage_error, - print_simple_usage_error_do, CliCommand, CliCommandMap, CommandLineInterface, GlobalOptions, + CliCommand, CliCommandMap, CommandLineInterface, GlobalOptions, generate_nested_usage, + generate_usage_str_do, print_help, print_nested_usage_error, print_simple_usage_error_do, }; use crate::{ApiFuture, ApiHandler, ApiMethod, RpcEnvironment}; diff --git a/proxmox-router/src/cli/completion.rs b/proxmox-router/src/cli/completion.rs index 2569f9a8..6b40b831 100644 --- a/proxmox-router/src/cli/completion.rs +++ b/proxmox-router/src/cli/completion.rs @@ -4,7 +4,7 @@ use proxmox_schema::*; use super::help_command_def; use super::{ - shellword_split_unclosed, CliCommand, CliCommandMap, CommandLineInterface, CompletionFunction, + CliCommand, CliCommandMap, CommandLineInterface, CompletionFunction, shellword_split_unclosed, }; fn record_done_argument( diff --git a/proxmox-router/src/cli/completion_helpers.rs b/proxmox-router/src/cli/completion_helpers.rs index 6469fcb7..89ec4318 100644 --- a/proxmox-router/src/cli/completion_helpers.rs +++ b/proxmox-router/src/cli/completion_helpers.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use nix::dir::Dir; use nix::fcntl::{AtFlags, OFlag}; -use nix::sys::stat::{fstatat, Mode}; +use nix::sys::stat::{Mode, fstatat}; pub fn complete_file_name(arg: &str, _param: &HashMap) -> Vec { let mut result = vec![]; diff --git a/proxmox-router/src/cli/format.rs b/proxmox-router/src/cli/format.rs index 61e2f172..6c967754 100644 --- a/proxmox-router/src/cli/format.rs +++ b/proxmox-router/src/cli/format.rs @@ -2,17 +2,17 @@ use std::collections::{HashMap, HashSet}; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use serde::Serialize; use serde_json::Value; use proxmox_schema::format::{ - get_property_description, get_schema_type_text, DocumentationFormat, ParameterDisplayStyle, + DocumentationFormat, ParameterDisplayStyle, get_property_description, get_schema_type_text, }; use proxmox_schema::*; -use super::{value_to_text, TableFormatOptions}; use super::{CliCommand, CliCommandMap, CommandLineInterface, GlobalOptions}; +use super::{TableFormatOptions, value_to_text}; /// Helper function to format and print result. /// diff --git a/proxmox-router/src/cli/mod.rs b/proxmox-router/src/cli/mod.rs index ae2bff6a..b1ab190d 100644 --- a/proxmox-router/src/cli/mod.rs +++ b/proxmox-router/src/cli/mod.rs @@ -17,7 +17,7 @@ use std::collections::HashMap; use std::io::{self, Write}; use std::sync::Arc; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use serde::Deserialize; use serde_json::Value; diff --git a/proxmox-router/src/cli/shellword.rs b/proxmox-router/src/cli/shellword.rs index dd7584f0..68493f66 100644 --- a/proxmox-router/src/cli/shellword.rs +++ b/proxmox-router/src/cli/shellword.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; /// Shell quote type pub use rustyline::completion::Quote; diff --git a/proxmox-router/src/cli/text_table.rs b/proxmox-router/src/cli/text_table.rs index bbeafb8d..9f68be86 100644 --- a/proxmox-router/src/cli/text_table.rs +++ b/proxmox-router/src/cli/text_table.rs @@ -1,6 +1,6 @@ use std::io::{IsTerminal, Write}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use serde_json::Value; use unicode_width::UnicodeWidthStr; diff --git a/proxmox-router/src/error.rs b/proxmox-router/src/error.rs index 15c5417f..69955507 100644 --- a/proxmox-router/src/error.rs +++ b/proxmox-router/src/error.rs @@ -1,4 +1,4 @@ -pub use proxmox_http_error::{http_bail, http_err, HttpError}; +pub use proxmox_http_error::{HttpError, http_bail, http_err}; #[doc(hidden)] pub use http::StatusCode; diff --git a/proxmox-router/src/format.rs b/proxmox-router/src/format.rs index c88b3ff7..85fabe8d 100644 --- a/proxmox-router/src/format.rs +++ b/proxmox-router/src/format.rs @@ -4,8 +4,8 @@ use std::io::Write; use anyhow::Error; -use proxmox_schema::format::*; use proxmox_schema::ObjectSchemaType; +use proxmox_schema::format::*; #[cfg(feature = "server")] use crate::ApiHandler; diff --git a/proxmox-router/src/permission.rs b/proxmox-router/src/permission.rs index e3be3387..f2d33a01 100644 --- a/proxmox-router/src/permission.rs +++ b/proxmox-router/src/permission.rs @@ -200,7 +200,7 @@ fn check_api_permission_tail( #[cfg(test)] mod test { - use serde_json::{json, Value}; + use serde_json::{Value, json}; use crate::permission::*; diff --git a/proxmox-router/src/router.rs b/proxmox-router/src/router.rs index f4207d2a..fea47ba6 100644 --- a/proxmox-router/src/router.rs +++ b/proxmox-router/src/router.rs @@ -44,10 +44,12 @@ use crate::SerializableReturn; /// &ObjectSchema::new("Hello World Example", &[]) /// ); /// ``` -pub type ApiHandlerFn = &'static (dyn Fn(Value, &ApiMethod, &mut dyn RpcEnvironment) -> Result - + Send - + Sync - + 'static); +pub type ApiHandlerFn = &'static ( + dyn Fn(Value, &ApiMethod, &mut dyn RpcEnvironment) -> Result + + Send + + Sync + + 'static + ); /// A synchronous API handler gets a json Value as input and returns a serializable return value as output. /// @@ -71,14 +73,16 @@ pub type ApiHandlerFn = &'static (dyn Fn(Value, &ApiMethod, &mut dyn RpcEnvironm /// &ObjectSchema::new("Hello World Example", &[]) /// ); /// ``` -pub type SerializingApiHandlerFn = &'static (dyn Fn( +pub type SerializingApiHandlerFn = &'static ( + dyn Fn( Value, &ApiMethod, &mut dyn RpcEnvironment, ) -> Result, Error> - + Send - + Sync - + 'static); + + Send + + Sync + + 'static + ); /// A record for a streaming API call. This contains a `Result` and allows formatting /// as a `json-seq` formatted string. @@ -183,10 +187,12 @@ where /// &ObjectSchema::new("Hello World Example", &[]) /// ); /// ``` -pub type StreamApiHandlerFn = &'static (dyn Fn(Value, &ApiMethod, &mut dyn RpcEnvironment) -> Result - + Send - + Sync - + 'static); +pub type StreamApiHandlerFn = &'static ( + dyn Fn(Value, &ApiMethod, &mut dyn RpcEnvironment) -> Result + + Send + + Sync + + 'static + ); pub struct SyncStream { inner: Box + Send>, @@ -246,9 +252,11 @@ where /// &ObjectSchema::new("Hello World Example (async)", &[]) /// ); /// ``` -pub type ApiAsyncHandlerFn = &'static (dyn for<'a> Fn(Value, &'static ApiMethod, &'a mut dyn RpcEnvironment) -> ApiFuture<'a> - + Send - + Sync); +pub type ApiAsyncHandlerFn = &'static ( + dyn for<'a> Fn(Value, &'static ApiMethod, &'a mut dyn RpcEnvironment) -> ApiFuture<'a> + + Send + + Sync + ); pub type ApiFuture<'a> = Pin> + Send + 'a>>; @@ -278,13 +286,15 @@ pub type ApiFuture<'a> = Pin Fn( +pub type SerializingApiAsyncHandlerFn = &'static ( + dyn for<'a> Fn( Value, &'static ApiMethod, &'a mut dyn RpcEnvironment, ) -> SerializingApiFuture<'a> - + Send - + Sync); + + Send + + Sync + ); pub type SerializingApiFuture<'a> = Pin< Box, anyhow::Error>> + Send + 'a>, @@ -321,13 +331,15 @@ pub type SerializingApiFuture<'a> = Pin< /// &ObjectSchema::new("Hello World Example (async)", &[]) /// ); /// ``` -pub type StreamApiAsyncHandlerFn = &'static (dyn for<'a> Fn( +pub type StreamApiAsyncHandlerFn = &'static ( + dyn for<'a> Fn( Value, &'static ApiMethod, &'a mut dyn RpcEnvironment, ) -> StreamApiFuture<'a> - + Send - + Sync); + + Send + + Sync + ); pub type StreamApiFuture<'a> = Pin> + Send + 'a>>; @@ -422,16 +434,18 @@ impl IntoRecord for Result { /// ); /// ``` #[cfg(feature = "server")] -pub type ApiAsyncHttpHandlerFn = &'static (dyn Fn( +pub type ApiAsyncHttpHandlerFn = &'static ( + dyn Fn( Parts, Incoming, Value, &'static ApiMethod, Box, ) -> ApiResponseFuture - + Send - + Sync - + 'static); + + Send + + Sync + + 'static + ); /// The output of an asynchronous API handler is a future yielding a `Response`. #[cfg(feature = "server")] @@ -472,10 +486,12 @@ pub type ApiResponseFuture = /// ); /// ``` #[cfg(feature = "server")] -pub type ApiAsyncHttpHandlerBodyParametersFn = &'static (dyn Fn(Parts, Value, &'static ApiMethod, Box) -> ApiResponseFuture - + Send - + Sync - + 'static); +pub type ApiAsyncHttpHandlerBodyParametersFn = &'static ( + dyn Fn(Parts, Value, &'static ApiMethod, Box) -> ApiResponseFuture + + Send + + Sync + + 'static + ); /// Enum for different types of API handler functions. #[non_exhaustive] diff --git a/proxmox-router/src/stream/parsing.rs b/proxmox-router/src/stream/parsing.rs index 975d7c11..dbdfe208 100644 --- a/proxmox-router/src/stream/parsing.rs +++ b/proxmox-router/src/stream/parsing.rs @@ -1,9 +1,9 @@ use std::future::Future; use std::io; use std::pin::Pin; -use std::task::{ready, Poll}; +use std::task::{Poll, ready}; -use anyhow::{format_err, Context as _, Error}; +use anyhow::{Context as _, Error, format_err}; use bytes::Bytes; use futures::io::{AsyncBufRead, AsyncBufReadExt, AsyncRead, BufReader}; use serde::Deserialize; diff --git a/proxmox-rrd/examples/prrd.rs b/proxmox-rrd/examples/prrd.rs index e29ce5cf..e71769a8 100644 --- a/proxmox-rrd/examples/prrd.rs +++ b/proxmox-rrd/examples/prrd.rs @@ -2,15 +2,15 @@ use std::path::PathBuf; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use serde::{Deserialize, Serialize}; use serde_json::json; -use proxmox_router::cli::{ - complete_file_name, run_cli_command, CliCommand, CliCommandMap, CliEnvironment, -}; use proxmox_router::RpcEnvironment; -use proxmox_schema::{api, ApiStringFormat, ApiType, IntegerSchema, Schema, StringSchema}; +use proxmox_router::cli::{ + CliCommand, CliCommandMap, CliEnvironment, complete_file_name, run_cli_command, +}; +use proxmox_schema::{ApiStringFormat, ApiType, IntegerSchema, Schema, StringSchema, api}; use proxmox_sys::fs::CreateOptions; diff --git a/proxmox-rrd/src/cache.rs b/proxmox-rrd/src/cache.rs index fe5c18ec..305c4c22 100644 --- a/proxmox-rrd/src/cache.rs +++ b/proxmox-rrd/src/cache.rs @@ -7,13 +7,13 @@ use std::sync::{Arc, RwLock}; use std::thread::spawn; use std::time::SystemTime; -use anyhow::{bail, format_err, Error}; -use crossbeam_channel::{bounded, TryRecvError}; +use anyhow::{Error, bail, format_err}; +use crossbeam_channel::{TryRecvError, bounded}; -use proxmox_sys::fs::{create_path, CreateOptions}; +use proxmox_sys::fs::{CreateOptions, create_path}; -use crate::rrd::{AggregationFn, DataSourceType, Database}; use crate::Entry; +use crate::rrd::{AggregationFn, DataSourceType, Database}; mod journal; use journal::*; diff --git a/proxmox-rrd/src/cache/journal.rs b/proxmox-rrd/src/cache/journal.rs index 80711021..f4840659 100644 --- a/proxmox-rrd/src/cache/journal.rs +++ b/proxmox-rrd/src/cache/journal.rs @@ -6,7 +6,7 @@ use std::path::PathBuf; use std::str::FromStr; use std::sync::Arc; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use crossbeam_channel::Receiver; use nix::fcntl::OFlag; diff --git a/proxmox-rrd/src/cache/rrd_map.rs b/proxmox-rrd/src/cache/rrd_map.rs index a50520ae..8311b0aa 100644 --- a/proxmox-rrd/src/cache/rrd_map.rs +++ b/proxmox-rrd/src/cache/rrd_map.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::path::Path; use std::sync::Arc; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use proxmox_sys::fs::create_path; diff --git a/proxmox-rrd/src/rrd.rs b/proxmox-rrd/src/rrd.rs index 29b686a8..19a88d84 100644 --- a/proxmox-rrd/src/rrd.rs +++ b/proxmox-rrd/src/rrd.rs @@ -15,11 +15,11 @@ use std::io::{Read, Write}; use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd}; use std::path::Path; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use serde::{Deserialize, Serialize}; use proxmox_schema::api; -use proxmox_sys::fs::{make_tmp_file, CreateOptions}; +use proxmox_sys::fs::{CreateOptions, make_tmp_file}; /// Proxmox RRD v2 file magic number // openssl::sha::sha256(b"Proxmox Round Robin Database file v2.0")[0..8]; diff --git a/proxmox-rrd/tests/file_format_test.rs b/proxmox-rrd/tests/file_format_test.rs index c505f829..1c2ded85 100644 --- a/proxmox-rrd/tests/file_format_test.rs +++ b/proxmox-rrd/tests/file_format_test.rs @@ -1,7 +1,7 @@ use std::path::Path; use std::process::Command; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use proxmox_rrd::rrd::Database; use proxmox_sys::fs::CreateOptions; diff --git a/proxmox-s3-client/src/api_types.rs b/proxmox-s3-client/src/api_types.rs index 93573fbd..43591c46 100644 --- a/proxmox-s3-client/src/api_types.rs +++ b/proxmox-s3-client/src/api_types.rs @@ -6,7 +6,7 @@ use proxmox_human_byte::HumanByte; use proxmox_schema::api_types::{ CERT_FINGERPRINT_SHA256_SCHEMA, DNS_LABEL_STR, IPRE_STR, SAFE_ID_FORMAT, }; -use proxmox_schema::{api, const_regex, ApiStringFormat, Schema, StringSchema, Updater}; +use proxmox_schema::{ApiStringFormat, Schema, StringSchema, Updater, api, const_regex}; #[rustfmt::skip] /// Regex to match S3 endpoint full qualified domain names, including template patterns for bucket diff --git a/proxmox-s3-client/src/aws_sign_v4.rs b/proxmox-s3-client/src/aws_sign_v4.rs index 7cbc7d1a..f172b4b4 100644 --- a/proxmox-s3-client/src/aws_sign_v4.rs +++ b/proxmox-s3-client/src/aws_sign_v4.rs @@ -1,6 +1,6 @@ //! Helpers for request authentication using AWS signature version 4 -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use hyper::Request; use openssl::hash::MessageDigest; use openssl::pkey::{PKey, Private}; diff --git a/proxmox-s3-client/src/client.rs b/proxmox-s3-client/src/client.rs index 83176b39..954eb79f 100644 --- a/proxmox-s3-client/src/client.rs +++ b/proxmox-s3-client/src/client.rs @@ -3,14 +3,14 @@ use std::str::FromStr; use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; -use anyhow::{bail, format_err, Context, Error}; +use anyhow::{Context, Error, bail, format_err}; use hyper::body::{Bytes, Incoming}; use hyper::http::method::Method; use hyper::http::uri::{Authority, Parts, PathAndQuery, Scheme}; -use hyper::http::{header, HeaderValue, StatusCode, Uri}; +use hyper::http::{HeaderValue, StatusCode, Uri, header}; use hyper::{Request, Response}; -use hyper_util::client::legacy::connect::HttpConnector; use hyper_util::client::legacy::Client; +use hyper_util::client::legacy::connect::HttpConnector; use hyper_util::rt::TokioExecutor; use nix::unistd::User; use openssl::hash::MessageDigest; @@ -19,8 +19,8 @@ use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode}; use openssl::x509::X509StoreContextRef; use tracing::error; -use proxmox_http::client::HttpsConnector; use proxmox_http::Body; +use proxmox_http::client::HttpsConnector; use proxmox_rate_limiter::{RateLimit, RateLimiter, SharedRateLimiter}; use proxmox_schema::api_types::CERT_FINGERPRINT_SHA256_SCHEMA; diff --git a/proxmox-s3-client/src/lib.rs b/proxmox-s3-client/src/lib.rs index d02fd0dc..7b0f46e4 100644 --- a/proxmox-s3-client/src/lib.rs +++ b/proxmox-s3-client/src/lib.rs @@ -21,7 +21,7 @@ pub use aws_sign_v4::uri_decode; mod client; #[cfg(feature = "impl")] pub use client::{ - S3Client, S3ClientOptions, S3PathPrefix, S3RateLimiterOptions, S3_HTTP_REQUEST_TIMEOUT, + S3_HTTP_REQUEST_TIMEOUT, S3Client, S3ClientOptions, S3PathPrefix, S3RateLimiterOptions, }; #[cfg(feature = "impl")] mod timestamps; diff --git a/proxmox-s3-client/src/object_key.rs b/proxmox-s3-client/src/object_key.rs index 34189409..d30458e2 100644 --- a/proxmox-s3-client/src/object_key.rs +++ b/proxmox-s3-client/src/object_key.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; /// Byte limit for s3 object keys. /// See https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html diff --git a/proxmox-s3-client/src/response_reader.rs b/proxmox-s3-client/src/response_reader.rs index e03b3bb0..18608d98 100644 --- a/proxmox-s3-client/src/response_reader.rs +++ b/proxmox-s3-client/src/response_reader.rs @@ -1,11 +1,11 @@ use std::str::FromStr; -use anyhow::{anyhow, bail, Context, Error}; +use anyhow::{Context, Error, anyhow, bail}; use http_body_util::BodyExt; use hyper::body::{Bytes, Incoming}; use hyper::header::HeaderName; -use hyper::http::header; use hyper::http::StatusCode; +use hyper::http::header; use hyper::{HeaderMap, Response}; use serde::Deserialize; @@ -628,7 +628,9 @@ fn test_optional_date_header_parsing() { assert!(ResponseReader::parse_optional_date_header(&header_map).is_err()); header_map.clear(); - assert!(ResponseReader::parse_optional_date_header(&header_map) - .unwrap() - .is_none()); + assert!( + ResponseReader::parse_optional_date_header(&header_map) + .unwrap() + .is_none() + ); } diff --git a/proxmox-s3-client/src/timestamps.rs b/proxmox-s3-client/src/timestamps.rs index 74397593..af4c7d71 100644 --- a/proxmox-s3-client/src/timestamps.rs +++ b/proxmox-s3-client/src/timestamps.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, bail, Context, Error}; +use anyhow::{Context, Error, anyhow, bail}; const VALID_DAYS_OF_WEEK: [&str; 7] = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; const VALID_MONTHS: [&str; 12] = [ diff --git a/proxmox-schema/src/de/mod.rs b/proxmox-schema/src/de/mod.rs index ea5661d8..d4105e8a 100644 --- a/proxmox-schema/src/de/mod.rs +++ b/proxmox-schema/src/de/mod.rs @@ -17,9 +17,9 @@ pub mod verify; pub use extract::ExtractValueDeserializer; -use cow3::{str_slice_to_range, Cow3}; +use cow3::{Cow3, str_slice_to_range}; -pub use no_schema::{split_list, SplitList}; +pub use no_schema::{SplitList, split_list}; // Used to disable calling `check_constraints` on a `StringSchema` if it is being deserialized // for a `PropertyString`, which performs its own checking. diff --git a/proxmox-schema/src/de/no_schema.rs b/proxmox-schema/src/de/no_schema.rs index 747ef44a..f5bf6c2e 100644 --- a/proxmox-schema/src/de/no_schema.rs +++ b/proxmox-schema/src/de/no_schema.rs @@ -4,8 +4,8 @@ use std::borrow::Cow; use serde::de; -use super::cow3::Cow3; use super::Error; +use super::cow3::Cow3; /// This can only deserialize strings and lists of strings and has no schema. pub struct NoSchemaDeserializer<'de, 'i> { diff --git a/proxmox-schema/src/format.rs b/proxmox-schema/src/format.rs index c1e33a68..6a8ebdd5 100644 --- a/proxmox-schema/src/format.rs +++ b/proxmox-schema/src/format.rs @@ -1,6 +1,6 @@ //! Module to generate and format API Documentation -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use crate::*; diff --git a/proxmox-schema/src/property_string.rs b/proxmox-schema/src/property_string.rs index b9351a6b..80ed4d09 100644 --- a/proxmox-schema/src/property_string.rs +++ b/proxmox-schema/src/property_string.rs @@ -196,14 +196,18 @@ fn iterate_over_property_string() { ); assert!(iter.next().is_none()); - assert!(PropertyIterator::new(r#"key="open \\ value"#) - .next() - .unwrap() - .is_err()); - assert!(PropertyIterator::new(r#"key="open \\ value\""#) - .next() - .unwrap() - .is_err()); + assert!( + PropertyIterator::new(r#"key="open \\ value"#) + .next() + .unwrap() + .is_err() + ); + assert!( + PropertyIterator::new(r#"key="open \\ value\""#) + .next() + .unwrap() + .is_err() + ); } /// A wrapper for a de/serializable type which is stored as a property string. @@ -267,7 +271,7 @@ where where D: serde::Deserializer<'de>, { - use crate::de::{set_in_property_string, InPropertyStringGuard}; + use crate::de::{InPropertyStringGuard, set_in_property_string}; use std::marker::PhantomData; diff --git a/proxmox-schema/src/schema.rs b/proxmox-schema/src/schema.rs index ddd11761..6f145402 100644 --- a/proxmox-schema/src/schema.rs +++ b/proxmox-schema/src/schema.rs @@ -7,8 +7,8 @@ use std::collections::HashSet; use std::fmt; -use anyhow::{bail, format_err, Error}; -use serde_json::{json, Value}; +use anyhow::{Error, bail, format_err}; +use serde_json::{Value, json}; use crate::ConstRegexPattern; diff --git a/proxmox-schema/src/upid.rs b/proxmox-schema/src/upid.rs index 6920a499..239abedd 100644 --- a/proxmox-schema/src/upid.rs +++ b/proxmox-schema/src/upid.rs @@ -1,6 +1,6 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; -use crate::{const_regex, ApiStringFormat, ApiType, Schema, StringSchema}; +use crate::{ApiStringFormat, ApiType, Schema, StringSchema, const_regex}; /// Unique Process/Task Identifier /// @@ -212,7 +212,7 @@ mod upid_impl { use std::os::unix::ffi::OsStrExt; use std::sync::atomic::{AtomicUsize, Ordering}; - use anyhow::{bail, format_err, Error}; + use anyhow::{Error, bail, format_err}; use super::UPID; diff --git a/proxmox-schema/tests/schema_verification.rs b/proxmox-schema/tests/schema_verification.rs index c7f43876..ee333359 100644 --- a/proxmox-schema/tests/schema_verification.rs +++ b/proxmox-schema/tests/schema_verification.rs @@ -1,5 +1,5 @@ -use anyhow::{bail, Error}; -use serde_json::{json, Value}; +use anyhow::{Error, bail}; +use serde_json::{Value, json}; use proxmox_schema::*; diff --git a/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs index fec6a423..c90e960e 100644 --- a/proxmox-section-config/src/lib.rs +++ b/proxmox-section-config/src/lib.rs @@ -24,13 +24,13 @@ use std::collections::HashMap; use std::collections::HashSet; use std::path::Path; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use serde::de::DeserializeOwned; use serde::ser::Serialize; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use proxmox_lang::try_block; -use proxmox_schema::format::{dump_properties, wrap_text, ParameterDisplayStyle}; +use proxmox_schema::format::{ParameterDisplayStyle, dump_properties, wrap_text}; use proxmox_schema::*; pub mod typed; diff --git a/proxmox-section-config/src/typed.rs b/proxmox-section-config/src/typed.rs index 55cb3c75..f56df917 100644 --- a/proxmox-section-config/src/typed.rs +++ b/proxmox-section-config/src/typed.rs @@ -6,8 +6,8 @@ use std::hash::Hash; use std::path::Path; use anyhow::Error; -use serde::{de::DeserializeOwned, Serialize}; -use serde_json::{json, Value}; +use serde::{Serialize, de::DeserializeOwned}; +use serde_json::{Value, json}; use crate::SectionConfig; use crate::SectionConfigData as RawSectionConfigData; diff --git a/proxmox-sendmail/src/lib.rs b/proxmox-sendmail/src/lib.rs index f5b04afd..ff8a2eb1 100644 --- a/proxmox-sendmail/src/lib.rs +++ b/proxmox-sendmail/src/lib.rs @@ -6,8 +6,8 @@ use std::io::Write; use std::process::{Command, Stdio}; -use anyhow::{bail, Context, Error}; -use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS}; +use anyhow::{Context, Error, bail}; +use percent_encoding::{AsciiSet, CONTROLS, utf8_percent_encode}; // Characters in this set will be encoded, so reproduce the inverse of the set described by RFC5987 // Section 3.2.1 `attr-char`, as that describes all characters that **don't** need encoding: diff --git a/proxmox-serde/src/json.rs b/proxmox-serde/src/json.rs index 63574d33..281114b9 100644 --- a/proxmox-serde/src/json.rs +++ b/proxmox-serde/src/json.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use serde_json::Value; diff --git a/proxmox-shared-cache/src/lib.rs b/proxmox-shared-cache/src/lib.rs index 65abc1ac..365b1650 100644 --- a/proxmox-shared-cache/src/lib.rs +++ b/proxmox-shared-cache/src/lib.rs @@ -4,8 +4,8 @@ use std::path::PathBuf; use std::time::Duration; use anyhow::Error; -use serde::de::DeserializeOwned; use serde::Serialize; +use serde::de::DeserializeOwned; use proxmox_sys::fs::CreateOptions; diff --git a/proxmox-shared-memory/src/lib.rs b/proxmox-shared-memory/src/lib.rs index b067d1b9..41a3a23c 100644 --- a/proxmox-shared-memory/src/lib.rs +++ b/proxmox-shared-memory/src/lib.rs @@ -9,7 +9,7 @@ use std::os::unix::io::AsRawFd; use std::os::unix::io::FromRawFd; use std::path::Path; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use nix::errno::Errno; use nix::fcntl::OFlag; use nix::sys::mman::{MapFlags, ProtFlags}; diff --git a/proxmox-shared-memory/src/shared_mutex.rs b/proxmox-shared-memory/src/shared_mutex.rs index 49adf5e5..90f1aa20 100644 --- a/proxmox-shared-memory/src/shared_mutex.rs +++ b/proxmox-shared-memory/src/shared_mutex.rs @@ -3,10 +3,10 @@ use std::marker::PhantomData; use std::mem::MaybeUninit; use std::ops::{Deref, DerefMut}; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; -use crate::raw_shared_mutex::RawSharedMutex; use crate::Init; +use crate::raw_shared_mutex::RawSharedMutex; #[derive(Debug)] #[repr(C)] diff --git a/proxmox-shared-memory/tests/raw_shared_mutex.rs b/proxmox-shared-memory/tests/raw_shared_mutex.rs index 7608377e..ac54a600 100644 --- a/proxmox-shared-memory/tests/raw_shared_mutex.rs +++ b/proxmox-shared-memory/tests/raw_shared_mutex.rs @@ -5,7 +5,7 @@ use anyhow::Error; use nix::fcntl::OFlag; use nix::sys::stat::Mode; use nix::unistd::mkdir; -use proxmox_shared_memory::{check_subtype, initialize_subtype, Init, SharedMemory, SharedMutex}; +use proxmox_shared_memory::{Init, SharedMemory, SharedMutex, check_subtype, initialize_subtype}; use proxmox_sys::fs::CreateOptions; use std::sync::atomic::AtomicU64; diff --git a/proxmox-simple-config/src/lib.rs b/proxmox-simple-config/src/lib.rs index 40ac434e..1e8ec5c7 100644 --- a/proxmox-simple-config/src/lib.rs +++ b/proxmox-simple-config/src/lib.rs @@ -4,7 +4,7 @@ use std::io::Write; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use serde::{Deserialize, Serialize}; use serde_json::Value; diff --git a/proxmox-sortable-macro/src/lib.rs b/proxmox-sortable-macro/src/lib.rs index 382a5562..c7b86319 100644 --- a/proxmox-sortable-macro/src/lib.rs +++ b/proxmox-sortable-macro/src/lib.rs @@ -9,10 +9,10 @@ use std::mem; use proc_macro::TokenStream as TokenStream_1; use proc_macro2::TokenStream; use quote::quote; +use syn::Error; use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::visit_mut::VisitMut; -use syn::Error; macro_rules! format_err { ($span:expr => $($msg:tt)*) => { Error::new_spanned($span, format!($($msg)*)) }; diff --git a/proxmox-subscription/src/check.rs b/proxmox-subscription/src/check.rs index 17306067..8fcd3f55 100644 --- a/proxmox-subscription/src/check.rs +++ b/proxmox-subscription/src/check.rs @@ -1,15 +1,15 @@ use std::sync::LazyLock; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use regex::Regex; use serde_json::json; -use proxmox_http::{uri::json_object_to_query, HttpClient}; +use proxmox_http::{HttpClient, uri::json_object_to_query}; use crate::{ - subscription_info::{md5sum, SHARED_KEY_DATA}, SubscriptionInfo, SubscriptionStatus, + subscription_info::{SHARED_KEY_DATA, md5sum}, }; static ATTR_RE: LazyLock = diff --git a/proxmox-subscription/src/files.rs b/proxmox-subscription/src/files.rs index a450e131..dd1e6a80 100644 --- a/proxmox-subscription/src/files.rs +++ b/proxmox-subscription/src/files.rs @@ -1,11 +1,11 @@ use std::path::Path; -use anyhow::{format_err, Error}; -use proxmox_sys::fs::{replace_file, CreateOptions}; +use anyhow::{Error, format_err}; +use proxmox_sys::fs::{CreateOptions, replace_file}; use crate::{ - subscription_info::{md5sum, SHARED_KEY_DATA}, SubscriptionInfo, SubscriptionStatus, + subscription_info::{SHARED_KEY_DATA, md5sum}, }; pub const DEFAULT_SIGNING_KEY: &str = "/usr/share/keyrings/proxmox-offline-signing-key.pub"; diff --git a/proxmox-subscription/src/lib.rs b/proxmox-subscription/src/lib.rs index 2ed96903..0e88d77c 100644 --- a/proxmox-subscription/src/lib.rs +++ b/proxmox-subscription/src/lib.rs @@ -3,7 +3,7 @@ mod subscription_info; #[cfg(feature = "impl")] pub use subscription_info::{ - get_hardware_address, ProductType, SubscriptionInfo, SubscriptionStatus, + ProductType, SubscriptionInfo, SubscriptionStatus, get_hardware_address, }; #[cfg(not(feature = "impl"))] diff --git a/proxmox-subscription/src/sign.rs b/proxmox-subscription/src/sign.rs index 50ee352b..40118d2f 100644 --- a/proxmox-subscription/src/sign.rs +++ b/proxmox-subscription/src/sign.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use openssl::{hash::MessageDigest, pkey::Public}; use serde::{Deserialize, Serialize}; diff --git a/proxmox-subscription/src/subscription_info.rs b/proxmox-subscription/src/subscription_info.rs index f53b3ce3..7f58b50a 100644 --- a/proxmox-subscription/src/subscription_info.rs +++ b/proxmox-subscription/src/subscription_info.rs @@ -1,10 +1,10 @@ use std::{fmt::Display, str::FromStr}; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use serde::{Deserialize, Serialize}; #[cfg(feature = "api-types")] -use proxmox_schema::{api, Updater}; +use proxmox_schema::{Updater, api}; // Aliases are needed for PVE compat! #[cfg_attr(feature = "api-types", api())] @@ -136,7 +136,7 @@ pub struct SubscriptionInfo { pub use _impl::get_hardware_address; #[cfg(feature = "impl")] -pub(crate) use _impl::{md5sum, SHARED_KEY_DATA}; +pub(crate) use _impl::{SHARED_KEY_DATA, md5sum}; #[cfg(feature = "impl")] mod _impl { @@ -144,8 +144,8 @@ mod _impl { use std::path::Path; use anyhow::format_err; - use anyhow::{bail, Error}; - use openssl::hash::{hash, DigestBytes, MessageDigest}; + use anyhow::{Error, bail}; + use openssl::hash::{DigestBytes, MessageDigest, hash}; use proxmox_sys::fs::file_get_contents; use proxmox_time::TmEditor; diff --git a/proxmox-sys/src/command.rs b/proxmox-sys/src/command.rs index bc2ff249..e64bd016 100644 --- a/proxmox-sys/src/command.rs +++ b/proxmox-sys/src/command.rs @@ -2,7 +2,7 @@ use std::process::{Command, Output}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; /// Helper to check result from [Command] output /// diff --git a/proxmox-sys/src/crypt.rs b/proxmox-sys/src/crypt.rs index 508b9c15..24abf9f6 100644 --- a/proxmox-sys/src/crypt.rs +++ b/proxmox-sys/src/crypt.rs @@ -5,7 +5,7 @@ use std::ffi::{CStr, CString}; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; // from libcrypt1, 'lib/crypt.h.in' const CRYPT_OUTPUT_SIZE: usize = 384; diff --git a/proxmox-sys/src/fd.rs b/proxmox-sys/src/fd.rs index 262c1208..130be820 100644 --- a/proxmox-sys/src/fd.rs +++ b/proxmox-sys/src/fd.rs @@ -2,13 +2,13 @@ use std::os::unix::io::AsRawFd; -use nix::sys::stat::Mode; use nix::NixPath; +use nix::sys::stat::Mode; use nix::{fcntl::OFlag, sys::stat}; use std::os::unix::io::{FromRawFd, OwnedFd, RawFd}; -use nix::fcntl::{fcntl, FdFlag, F_GETFD, F_SETFD}; +use nix::fcntl::{F_GETFD, F_SETFD, FdFlag, fcntl}; /// Change the `O_CLOEXEC` flag of an existing file descriptor. pub fn fd_change_cloexec(fd: RawFd, on: bool) -> Result<(), anyhow::Error> { diff --git a/proxmox-sys/src/fs/acl.rs b/proxmox-sys/src/fs/acl.rs index 4aabb454..cc26baa6 100644 --- a/proxmox-sys/src/fs/acl.rs +++ b/proxmox-sys/src/fs/acl.rs @@ -11,8 +11,8 @@ use std::path::Path; use std::ptr; use libc::{c_char, c_int, c_void}; -use nix::errno::Errno; use nix::NixPath; +use nix::errno::Errno; #[rustfmt::skip] mod constants { diff --git a/proxmox-sys/src/fs/dir.rs b/proxmox-sys/src/fs/dir.rs index d0e94f3a..10afd4c6 100644 --- a/proxmox-sys/src/fs/dir.rs +++ b/proxmox-sys/src/fs/dir.rs @@ -4,7 +4,7 @@ use std::os::unix::ffi::OsStringExt; use std::os::unix::io::{AsRawFd, OwnedFd}; use std::path::{Path, PathBuf}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use nix::errno::Errno; use nix::fcntl::OFlag; use nix::sys::stat; @@ -12,7 +12,7 @@ use nix::unistd; use proxmox_lang::try_block; -use crate::fs::{fchown, CreateOptions}; +use crate::fs::{CreateOptions, fchown}; /// The default list of [`OFlag`]'s we want to use when opening directories. Besides ensuring that /// the FD indeed points to a directory we also must ensure that it gets closed on exec to avoid diff --git a/proxmox-sys/src/fs/file.rs b/proxmox-sys/src/fs/file.rs index 114527c7..c0b34061 100644 --- a/proxmox-sys/src/fs/file.rs +++ b/proxmox-sys/src/fs/file.rs @@ -5,12 +5,12 @@ use std::path::{Path, PathBuf}; #[cfg(feature = "timer")] use std::time::Duration; -use anyhow::{bail, format_err, Context as _, Error}; +use anyhow::{Context as _, Error, bail, format_err}; +use nix::NixPath; use nix::errno::Errno; use nix::fcntl::OFlag; use nix::sys::stat; use nix::unistd; -use nix::NixPath; use serde_json::Value; use crate::error::SysError; diff --git a/proxmox-sys/src/fs/mod.rs b/proxmox-sys/src/fs/mod.rs index 752b75d2..6cda6326 100644 --- a/proxmox-sys/src/fs/mod.rs +++ b/proxmox-sys/src/fs/mod.rs @@ -1,7 +1,7 @@ //! File system related utilities use std::path::Path; -use anyhow::{bail, Context, Error}; +use anyhow::{Context, Error, bail}; use nix::sys::stat; use nix::unistd::{Gid, Uid}; diff --git a/proxmox-sys/src/fs/read_dir.rs b/proxmox-sys/src/fs/read_dir.rs index d8330cd1..902b901b 100644 --- a/proxmox-sys/src/fs/read_dir.rs +++ b/proxmox-sys/src/fs/read_dir.rs @@ -2,7 +2,7 @@ use std::borrow::{Borrow, BorrowMut}; use std::ops::{Deref, DerefMut}; use std::os::unix::io::{AsRawFd, RawFd}; -use anyhow::{format_err, Error}; +use anyhow::{Error, format_err}; use nix::dir; use nix::dir::Dir; use nix::fcntl::OFlag; diff --git a/proxmox-sys/src/linux/mod.rs b/proxmox-sys/src/linux/mod.rs index b6efddbb..cfc85757 100644 --- a/proxmox-sys/src/linux/mod.rs +++ b/proxmox-sys/src/linux/mod.rs @@ -1,6 +1,6 @@ //! Linux specific helpers and syscall wrapper -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use proxmox_io::vec; diff --git a/proxmox-sys/src/linux/pid.rs b/proxmox-sys/src/linux/pid.rs index 03464551..020cb3d1 100644 --- a/proxmox-sys/src/linux/pid.rs +++ b/proxmox-sys/src/linux/pid.rs @@ -4,12 +4,12 @@ use std::fs::File; use std::io; use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; +use nix::NixPath; use nix::fcntl::OFlag; use nix::sys::signal::Signal; use nix::sys::signalfd::siginfo; use nix::sys::stat::Mode; use nix::unistd::Pid; -use nix::NixPath; use crate::error::SysResult; use crate::linux::procfs::{MountInfo, PidStat}; diff --git a/proxmox-sys/src/linux/procfs/mod.rs b/proxmox-sys/src/linux/procfs/mod.rs index 202b6a45..5bba65d9 100644 --- a/proxmox-sys/src/linux/procfs/mod.rs +++ b/proxmox-sys/src/linux/procfs/mod.rs @@ -8,7 +8,7 @@ use std::str::FromStr; use std::sync::{LazyLock, RwLock}; use std::time::Instant; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use nix::unistd::Pid; use serde::Serialize; diff --git a/proxmox-sys/src/linux/procfs/mountinfo.rs b/proxmox-sys/src/linux/procfs/mountinfo.rs index 6cedbb84..ed0b81ed 100644 --- a/proxmox-sys/src/linux/procfs/mountinfo.rs +++ b/proxmox-sys/src/linux/procfs/mountinfo.rs @@ -6,7 +6,7 @@ use std::os::unix::ffi::OsStrExt; use std::path::PathBuf; use std::str::FromStr; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use nix::sys::stat; use nix::unistd::Pid; diff --git a/proxmox-sys/src/linux/tty.rs b/proxmox-sys/src/linux/tty.rs index d08ae81f..54ce1409 100644 --- a/proxmox-sys/src/linux/tty.rs +++ b/proxmox-sys/src/linux/tty.rs @@ -2,7 +2,7 @@ use std::io::{self, IsTerminal, Read, Write}; use std::mem::MaybeUninit; use std::os::unix::io::{AsRawFd, OwnedFd}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use nix::fcntl::OFlag; use nix::sys::stat::Mode; diff --git a/proxmox-sys/src/logrotate.rs b/proxmox-sys/src/logrotate.rs index cb96974a..a995fab1 100644 --- a/proxmox-sys/src/logrotate.rs +++ b/proxmox-sys/src/logrotate.rs @@ -1,14 +1,14 @@ //! Log rotation helper -use std::fs::{rename, File}; +use std::fs::{File, rename}; use std::io::Read; use std::os::unix::io::{FromRawFd, IntoRawFd}; use std::path::{Path, PathBuf}; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use nix::unistd; -use crate::fs::{make_tmp_file, CreateOptions}; +use crate::fs::{CreateOptions, make_tmp_file}; /// Used for rotating log files and iterating over them pub struct LogRotate { diff --git a/proxmox-sys/src/macros.rs b/proxmox-sys/src/macros.rs index a76db90f..1838acf3 100644 --- a/proxmox-sys/src/macros.rs +++ b/proxmox-sys/src/macros.rs @@ -16,7 +16,5 @@ macro_rules! c_result { /// doing `c_result!(expr)?` (note the question mark). #[macro_export] macro_rules! c_try { - ($expr:expr) => {{ - $crate::c_result!($expr)? - }}; + ($expr:expr) => {{ $crate::c_result!($expr)? }}; } diff --git a/proxmox-sys/src/process_locker.rs b/proxmox-sys/src/process_locker.rs index b5d0944f..0b732ed1 100644 --- a/proxmox-sys/src/process_locker.rs +++ b/proxmox-sys/src/process_locker.rs @@ -11,7 +11,7 @@ use std::collections::HashMap; use std::os::unix::io::AsRawFd; use std::sync::{Arc, Mutex}; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; // fixme: use F_OFD_ locks when implemented with nix::fcntl diff --git a/proxmox-sys/src/systemd.rs b/proxmox-sys/src/systemd.rs index 99449377..693bcccf 100644 --- a/proxmox-sys/src/systemd.rs +++ b/proxmox-sys/src/systemd.rs @@ -2,7 +2,7 @@ use std::ffi::OsString; use std::os::unix::ffi::OsStringExt; use std::path::PathBuf; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; #[allow(clippy::manual_range_contains)] fn parse_hex_digit(d: u8) -> Result { diff --git a/proxmox-systemd/src/journal.rs b/proxmox-systemd/src/journal.rs index a06e247e..f23e97f0 100644 --- a/proxmox-systemd/src/journal.rs +++ b/proxmox-systemd/src/journal.rs @@ -1,4 +1,4 @@ -use std::ffi::{c_int, CString, OsStr}; +use std::ffi::{CString, OsStr, c_int}; use std::io; use std::os::fd::{FromRawFd, OwnedFd}; use std::os::unix::ffi::OsStrExt; diff --git a/proxmox-systemd/src/lib.rs b/proxmox-systemd/src/lib.rs index 456d88c3..d7d270bc 100644 --- a/proxmox-systemd/src/lib.rs +++ b/proxmox-systemd/src/lib.rs @@ -3,7 +3,7 @@ pub(crate) mod sys; mod escape; -pub use escape::{escape_unit, unescape_unit, unescape_unit_path, UnescapeError}; +pub use escape::{UnescapeError, escape_unit, unescape_unit, unescape_unit_path}; pub mod journal; pub mod notify; diff --git a/proxmox-systemd/src/notify.rs b/proxmox-systemd/src/notify.rs index 09aec233..9ae6a2ca 100644 --- a/proxmox-systemd/src/notify.rs +++ b/proxmox-systemd/src/notify.rs @@ -1,4 +1,4 @@ -use std::ffi::{c_char, c_void, CStr, CString}; +use std::ffi::{CStr, CString, c_char, c_void}; use std::io; use std::os::fd::{AsFd, AsRawFd, RawFd}; diff --git a/proxmox-tfa/src/api/methods.rs b/proxmox-tfa/src/api/methods.rs index a165400a..8ee7de71 100644 --- a/proxmox-tfa/src/api/methods.rs +++ b/proxmox-tfa/src/api/methods.rs @@ -3,7 +3,7 @@ //! This defines the methods & types used in the authentication and TFA configuration API between //! PBS, PVE, PMG. -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use super::{OpenUserChallengeData, TfaConfig, TfaInfo, TfaUserData}; use crate::totp::Totp; diff --git a/proxmox-tfa/src/api/mod.rs b/proxmox-tfa/src/api/mod.rs index f8188346..016c9edc 100644 --- a/proxmox-tfa/src/api/mod.rs +++ b/proxmox-tfa/src/api/mod.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use std::fmt; -use anyhow::{bail, format_err, Context as _, Error}; +use anyhow::{Context as _, Error, bail, format_err}; use serde::{Deserialize, Serialize}; use serde_json::Value; use url::Url; diff --git a/proxmox-tfa/src/api/recovery.rs b/proxmox-tfa/src/api/recovery.rs index 9629d6ff..7a40c412 100644 --- a/proxmox-tfa/src/api/recovery.rs +++ b/proxmox-tfa/src/api/recovery.rs @@ -1,6 +1,6 @@ use std::io; -use anyhow::{format_err, Error}; +use anyhow::{Error, format_err}; use openssl::hash::MessageDigest; use openssl::pkey::PKey; use openssl::sign::Signer; diff --git a/proxmox-tfa/src/api/webauthn.rs b/proxmox-tfa/src/api/webauthn.rs index 8c08401c..21f4ddd4 100644 --- a/proxmox-tfa/src/api/webauthn.rs +++ b/proxmox-tfa/src/api/webauthn.rs @@ -2,7 +2,7 @@ use std::fmt; -use anyhow::{format_err, Context as _, Error}; +use anyhow::{Context as _, Error, format_err}; use serde::{Deserialize, Serialize}; use url::Url; use webauthn_rs::prelude::SecurityKeyAuthentication; @@ -10,7 +10,7 @@ use webauthn_rs::prelude::SecurityKeyRegistration; use webauthn_rs_core::proto::{COSEKey, CredentialID, UserVerificationPolicy}; #[cfg(feature = "api-types")] -use proxmox_schema::{api, Updater, UpdaterType}; +use proxmox_schema::{Updater, UpdaterType, api}; use super::IsExpired; diff --git a/proxmox-tfa/src/totp.rs b/proxmox-tfa/src/totp.rs index aac584d0..e65c167b 100644 --- a/proxmox-tfa/src/totp.rs +++ b/proxmox-tfa/src/totp.rs @@ -8,7 +8,7 @@ use std::time::{Duration, SystemTime}; use openssl::hash::MessageDigest; use openssl::pkey::PKey; use openssl::sign::Signer; -use percent_encoding::{percent_decode, percent_encode, PercentDecode}; +use percent_encoding::{PercentDecode, percent_decode, percent_encode}; use serde::{Serialize, Serializer}; /// An error from the TOTP TFA submodule. diff --git a/proxmox-tfa/src/u2f.rs b/proxmox-tfa/src/u2f.rs index 0265e935..51416823 100644 --- a/proxmox-tfa/src/u2f.rs +++ b/proxmox-tfa/src/u2f.rs @@ -503,8 +503,7 @@ mod test { const TEST_APPID: &str = "https://u2ftest.enonet.errno.eu"; - const TEST_REGISTRATION_JSON: &str = - "{\"challenge\":\"mZoWLngnAh8p98nPkFOIBXecd0CbmgEx5tEd5jNswgY\",\"response\":{\"client\ + const TEST_REGISTRATION_JSON: &str = "{\"challenge\":\"mZoWLngnAh8p98nPkFOIBXecd0CbmgEx5tEd5jNswgY\",\"response\":{\"client\ Data\":\"eyJjaGFsbGVuZ2UiOiJtWm9XTG5nbkFoOHA5OG5Qa0ZPSUJYZWNkMENibWdFeDV0RWQ1ak5zd2dZI\ iwib3JpZ2luIjoiaHR0cHM6Ly91MmZ0ZXN0LmVub25ldC5lcnJuby5ldSIsInR5cCI6Im5hdmlnYXRvci5pZC5\ maW5pc2hFbnJvbGxtZW50In0\",\"registrationData\":\"BQR_9TmMowVeoAHp3ABljCa90eNG87t76D4W\ @@ -522,8 +521,7 @@ mod test { SbtOrrwswjOKEzwp6EonkCIFBxbLAmwUnblAWOVELASi610ZfPK-7qx2VwkWfHqnll\",\"version\":\"U2F\ _V2\"}}"; - const TEST_AUTH_JSON: &str = - "{\"challenge\":\"8LE_-7Rd1vB3Otn3vJ7GyiwRQtYPMv-BWliCejH0d4Y\",\"response\":{\"clientD\ + const TEST_AUTH_JSON: &str = "{\"challenge\":\"8LE_-7Rd1vB3Otn3vJ7GyiwRQtYPMv-BWliCejH0d4Y\",\"response\":{\"clientD\ ata\":\"eyJjaGFsbGVuZ2UiOiI4TEVfLTdSZDF2QjNPdG4zdko3R3lpd1JRdFlQTXYtQldsaUNlakgwZDRZIiw\ ib3JpZ2luIjoiaHR0cHM6Ly91MmZ0ZXN0LmVub25ldC5lcnJuby5ldSIsInR5cCI6Im5hdmlnYXRvci5pZC5nZX\ RBc3NlcnRpb24ifQ\",\"keyHandle\":\"eW3zVxEF8gPsG8eT9cgllzmSzkPdHVlXXV8m52ncX6KL8pJ1loVv\ diff --git a/proxmox-time-api/src/time_impl.rs b/proxmox-time-api/src/time_impl.rs index 383bae11..ffa8fa8b 100644 --- a/proxmox-time-api/src/time_impl.rs +++ b/proxmox-time-api/src/time_impl.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use proxmox_product_config::replace_system_config; use proxmox_sys::fs::file_read_firstline; diff --git a/proxmox-time/src/calendar_event.rs b/proxmox-time/src/calendar_event.rs index 696a11a2..22a4b340 100644 --- a/proxmox-time/src/calendar_event.rs +++ b/proxmox-time/src/calendar_event.rs @@ -9,8 +9,8 @@ use nom::{ }; use crate::date_time_value::DateTimeValue; -use crate::parse_helpers::{parse_complete_line, parse_error, parse_time_comp, IResult}; -use crate::{parse_weekdays_range, WeekDays}; +use crate::parse_helpers::{IResult, parse_complete_line, parse_error, parse_time_comp}; +use crate::{WeekDays, parse_weekdays_range}; /// Calendar events may be used to refer to one or more points in time in a /// single expression. They are designed after the systemd.time Calendar Events diff --git a/proxmox-time/src/daily_duration.rs b/proxmox-time/src/daily_duration.rs index adcbc637..df24b42c 100644 --- a/proxmox-time/src/daily_duration.rs +++ b/proxmox-time/src/daily_duration.rs @@ -5,8 +5,8 @@ use nom::{ bytes::complete::tag, character::complete::space0, error::context, multi::separated_list1, }; -use crate::parse_helpers::{parse_complete_line, parse_error, parse_hm_time, IResult}; -use crate::{parse_weekdays_range, WeekDays}; +use crate::parse_helpers::{IResult, parse_complete_line, parse_error, parse_hm_time}; +use crate::{WeekDays, parse_weekdays_range}; #[cfg(not(target_arch = "wasm32"))] use crate::TmEditor; @@ -127,7 +127,7 @@ fn parse_daily_duration_incomplete(mut i: &str) -> IResult<&str, DailyDuration> #[cfg(test)] mod test { - use anyhow::{bail, Error}; + use anyhow::{Error, bail}; use super::*; diff --git a/proxmox-time/src/parse_helpers.rs b/proxmox-time/src/parse_helpers.rs index 94d077f9..8afa8ccf 100644 --- a/proxmox-time/src/parse_helpers.rs +++ b/proxmox-time/src/parse_helpers.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use super::daily_duration::*; diff --git a/proxmox-time/src/posix.rs b/proxmox-time/src/posix.rs index c2146c47..2a9fc74a 100644 --- a/proxmox-time/src/posix.rs +++ b/proxmox-time/src/posix.rs @@ -2,7 +2,7 @@ use std::ffi::{CStr, CString}; -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; /// Safe bindings to libc timelocal /// diff --git a/proxmox-time/src/test.rs b/proxmox-time/src/test.rs index 44054c9c..91aba2db 100644 --- a/proxmox-time/src/test.rs +++ b/proxmox-time/src/test.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use super::*; diff --git a/proxmox-time/src/time_span.rs b/proxmox-time/src/time_span.rs index 6081a534..5b6b30ef 100644 --- a/proxmox-time/src/time_span.rs +++ b/proxmox-time/src/time_span.rs @@ -44,7 +44,7 @@ use std::sync::LazyLock; use anyhow::Error; use nom::{bytes::complete::take_while1, character::complete::space0, combinator::opt}; -use crate::parse_helpers::{parse_complete_line, parse_error, parse_u64, IResult}; +use crate::parse_helpers::{IResult, parse_complete_line, parse_error, parse_u64}; static TIME_SPAN_UNITS: LazyLock> = LazyLock::new(|| { let mut map = HashMap::new(); diff --git a/proxmox-time/src/wasm.rs b/proxmox-time/src/wasm.rs index c85f2a10..38ddd316 100644 --- a/proxmox-time/src/wasm.rs +++ b/proxmox-time/src/wasm.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; /// Returns Unix Epoch (now) pub fn epoch_i64() -> i64 { diff --git a/proxmox-time/src/week_days.rs b/proxmox-time/src/week_days.rs index c409d292..3948ff5c 100644 --- a/proxmox-time/src/week_days.rs +++ b/proxmox-time/src/week_days.rs @@ -1,7 +1,7 @@ use bitflags::bitflags; use nom::{bytes::complete::tag, character::complete::alpha1, combinator::opt, sequence::pair}; -use crate::parse_helpers::{parse_error, IResult}; +use crate::parse_helpers::{IResult, parse_error}; bitflags! { /// Defines one or more days of a week. diff --git a/proxmox-upgrade-checks/src/lib.rs b/proxmox-upgrade-checks/src/lib.rs index 93080bb7..7f833282 100644 --- a/proxmox-upgrade-checks/src/lib.rs +++ b/proxmox-upgrade-checks/src/lib.rs @@ -1,7 +1,7 @@ use std::path::Path; use std::{io::Write, path::PathBuf}; -use anyhow::{format_err, Error}; +use anyhow::{Error, format_err}; use const_format::concatcp; use regex::Regex; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; diff --git a/proxmox-uuid/src/lib.rs b/proxmox-uuid/src/lib.rs index 793b5761..620a2767 100644 --- a/proxmox-uuid/src/lib.rs +++ b/proxmox-uuid/src/lib.rs @@ -61,7 +61,7 @@ pub struct Uuid(Box<[u8; 16]>); impl Uuid { /// Generate a uuid with `uuid_generate(3)`. pub fn generate() -> Self { - use std::alloc::{alloc, Layout}; + use std::alloc::{Layout, alloc}; let uuid = unsafe { alloc(Layout::new::<[u8; 16]>()) as *mut [u8; 16] }; unsafe { uuid_generate(uuid) }; Self(unsafe { Box::from_raw(uuid) }) @@ -92,7 +92,7 @@ impl Uuid { /// assert_eq!(uuid1, uuid2); /// ``` pub fn parse_str(src: &str) -> Result { - use std::alloc::{alloc, Layout}; + use std::alloc::{Layout, alloc}; let uuid: *mut [u8; 16] = unsafe { alloc(Layout::new::<[u8; 16]>()) as *mut [u8; 16] }; if src.len() == 36 { // Unfortunately the manpage of `uuid_parse(3)` states that it technically requires a diff --git a/proxmox-worker-task/src/lib.rs b/proxmox-worker-task/src/lib.rs index 743ae53f..d6d7b330 100644 --- a/proxmox-worker-task/src/lib.rs +++ b/proxmox-worker-task/src/lib.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; /// Worker task abstraction /// diff --git a/pve-api-types/src/types/mod.rs b/pve-api-types/src/types/mod.rs index d6a09539..2e2aba2e 100644 --- a/pve-api-types/src/types/mod.rs +++ b/pve-api-types/src/types/mod.rs @@ -4,17 +4,17 @@ use std::collections::HashMap; -use anyhow::{bail, Error}; +use anyhow::{Error, bail}; use serde::{Deserialize, Serialize}; use serde_json::Value; -use proxmox_schema::{api, const_regex, ApiStringFormat, ApiType, Schema, StringSchema}; +use proxmox_schema::{ApiStringFormat, ApiType, Schema, StringSchema, api, const_regex}; mod macros; +pub(crate) use macros::__DIGIT_SPACE; pub(crate) use macros::__fill_names; pub(crate) use macros::__fill_properties; use macros::generate_array_field; -pub(crate) use macros::__DIGIT_SPACE; pub mod array; pub mod stringlist; diff --git a/pve-api-types/src/types/verifiers.rs b/pve-api-types/src/types/verifiers.rs index 25098b6f..eac4f871 100644 --- a/pve-api-types/src/types/verifiers.rs +++ b/pve-api-types/src/types/verifiers.rs @@ -1,6 +1,6 @@ //! Verifier functions for the schema. -use anyhow::{bail, format_err, Error}; +use anyhow::{Error, bail, format_err}; use proxmox_schema::const_regex; -- 2.47.3 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel