rust: Run rustfmt with some experimental options

+ Sort and group the imports
+ Normalize and format comments (100 characters width)

Command used:

$ cargo +nightly fmt --

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2026-05-11 14:43:53 +02:00
committed by Jan Höppner
parent 3d5f75d6c3
commit f8fb9ce32a
120 changed files with 825 additions and 900 deletions

View File

@@ -2,21 +2,17 @@
//
// Copyright IBM Corp. 2023, 2024
use clap::{ArgAction, ArgGroup, Args, Command, ValueHint};
use log::{info, warn, LevelFilter};
use pv::misc::read_file;
use pv::{
misc::{create_file, open_file, read_certs},
request::{
openssl::pkey::{PKey, Public},
HkdVerifier,
},
Error, Result,
};
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::process::ExitCode;
use clap::{ArgAction, ArgGroup, Args, Command, ValueHint};
use log::{info, warn, LevelFilter};
use pv::misc::{create_file, open_file, read_certs, read_file};
use pv::request::openssl::pkey::{PKey, Public};
use pv::request::HkdVerifier;
use pv::{Error, Result};
/// CLI Argument collection for handling host-keys, IBM signing keys, and certificates.
#[derive(Args, Debug, Clone, PartialEq, Eq, Default)]
#[command(

View File

@@ -88,7 +88,8 @@ macro_rules! impl_exitcodetrait {
#[cfg(test)]
mod tests {
use crate::{exit_code::ExitCodeDoc, ExitCodeTrait, ExitCodeVariantDoc};
use crate::exit_code::ExitCodeDoc;
use crate::{ExitCodeTrait, ExitCodeVariantDoc};
#[test]
fn test_impl_exitcodetrait_with_doc() {

View File

@@ -2,13 +2,11 @@
//
// Copyright IBM Corp. 2024
use std::{
ffi::OsStr,
fs::{rename, File, OpenOptions},
io::{self, Seek, SeekFrom, Write},
os::unix::fs::OpenOptionsExt,
path::Path,
};
use std::ffi::OsStr;
use std::fs::{rename, File, OpenOptions};
use std::io::{self, Seek, SeekFrom, Write};
use std::os::unix::fs::OpenOptionsExt;
use std::path::Path;
use pv::{Error, FileAccessErrorType, PvCoreError, Result};
@@ -80,7 +78,8 @@ impl AtomicFile<File> {
/// ```
/// # use utils::AtomicFile;
///
/// let file = AtomicFile::with_extension("test", ".incomplete", &mut std::fs::OpenOptions::new()).unwrap();
/// let file = AtomicFile::with_extension("test", ".incomplete", &mut std::fs::OpenOptions::new())
/// .unwrap();
/// ```
pub fn with_extension<P: AsRef<Path>, S: AsRef<OsStr>>(
output: P,

View File

@@ -2,9 +2,10 @@
//
// Copyright IBM Corp. 2024
use serde::Serialize;
use std::fmt::{Display, Formatter};
use serde::Serialize;
/// Displays/Serializes an u8-slice into a Hex-string
///
/// Thin wrapper around an u8-slice.

View File

@@ -2,7 +2,8 @@
//
// Copyright IBM Corp. 2026
use std::{ffi::CStr, io};
use std::ffi::CStr;
use std::io;
/// Returns the maximum hostname length supported by the system.
///
@@ -12,7 +13,8 @@ use std::{ffi::CStr, io};
fn max_hostname_len() -> usize {
const _POSIX_HOST_NAME_MAX: usize = 255;
// SAFETY: sysconf is safe to call with _SC_HOST_NAME_MAX and only reads system configuration without side effects.
// SAFETY: sysconf is safe to call with _SC_HOST_NAME_MAX and only reads system configuration
// without side effects.
let n = unsafe { libc::sysconf(libc::_SC_HOST_NAME_MAX) };
if n < 0 {
_POSIX_HOST_NAME_MAX

View File

@@ -14,20 +14,18 @@ mod tmpfile;
pub use ::log::LevelFilter;
pub use crate::{
cli::{
combined_path_opt, combined_path_req, get_reader_from_cli_file_arg,
get_writer_from_cli_file_arg, print_cli_error, print_error, CertificateOptions,
DeprecatedVerbosityOptions, VerbosityOptions, STDIN, STDOUT,
},
exit_code::{docstring, ExitCodeDoc, ExitCodeTrait, ExitCodeVariantDoc},
file::{AtomicFile, AtomicFileOperation},
hexslice::HexSlice,
hostname::gethostname,
json::S390ToolsMetaData,
log::PvLogger,
tmpfile::TemporaryDirectory,
pub use crate::cli::{
combined_path_opt, combined_path_req, get_reader_from_cli_file_arg,
get_writer_from_cli_file_arg, print_cli_error, print_error, CertificateOptions,
DeprecatedVerbosityOptions, VerbosityOptions, STDIN, STDOUT,
};
pub use crate::exit_code::{docstring, ExitCodeDoc, ExitCodeTrait, ExitCodeVariantDoc};
pub use crate::file::{AtomicFile, AtomicFileOperation};
pub use crate::hexslice::HexSlice;
pub use crate::hostname::gethostname;
pub use crate::json::S390ToolsMetaData;
pub use crate::log::PvLogger;
pub use crate::tmpfile::TemporaryDirectory;
/// Get the s390-tools release string
///

View File

@@ -2,11 +2,9 @@
//
// Copyright IBM Corp. 2024
use std::{
ffi::{CString, OsStr},
os::unix::prelude::OsStrExt,
path::{Path, PathBuf},
};
use std::ffi::{CString, OsStr};
use std::os::unix::prelude::OsStrExt;
use std::path::{Path, PathBuf};
/// Rust wrapper for `libc::mkdtemp`
fn mkdtemp<P: AsRef<Path>>(template: P) -> Result<PathBuf, std::io::Error> {