cargo fmt + clippy

This commit is contained in:
Oystein Kristoffer Tveit 2024-08-19 17:52:16 +02:00
parent 3556eb37ea
commit d1d06514a9
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
6 changed files with 23 additions and 19 deletions

View File

@ -60,7 +60,7 @@ The Y/N-values corresponds to the following mysql privileges:
version,
about,
disable_help_subcommand = true,
verbatim_doc_comment,
verbatim_doc_comment
)]
pub struct Args {
#[command(subcommand)]

View File

@ -36,7 +36,7 @@ use crate::{
version,
about,
disable_help_subcommand = true,
verbatim_doc_comment,
verbatim_doc_comment
)]
pub struct Args {
#[command(subcommand)]

View File

@ -32,15 +32,18 @@ pub fn drop_privs() -> anyhow::Result<()> {
/// This function is used to bootstrap the connection to the server.
/// This can happen in two ways:
///
/// 1. If a socket path is provided, or exists in the default location,
/// the function will connect to the socket and authenticate with the
/// server to ensure that the server knows the uid of the client.
///
/// 2. If a config path is provided, or exists in the default location,
/// and the config is readable, the function will assume it is either
/// setuid or setgid, and will fork a child process to run the server
/// with the provided config. The server will exit silently by itself
/// when it is done, and this function will only return for the client
/// with the socket for the server.
///
/// If neither of these options are available, the function will fail.
pub fn bootstrap_server_connection_and_drop_privileges(
server_socket_path: Option<PathBuf>,

View File

@ -109,17 +109,17 @@ fn main() -> anyhow::Result<()> {
env_logger::init();
#[cfg(feature = "mysql-admutils-compatibility")]
if let Some(_) = handle_mysql_admutils_command()? {
if handle_mysql_admutils_command()?.is_some() {
return Ok(());
}
let args: Args = Args::parse();
if let Some(_) = handle_server_command(&args)? {
if handle_server_command(&args)?.is_some() {
return Ok(());
}
if let Some(_) = handle_generate_completions_command(&args)? {
if handle_generate_completions_command(&args)?.is_some() {
return Ok(());
}
@ -139,8 +139,8 @@ fn handle_mysql_admutils_command() -> anyhow::Result<Option<()>> {
});
match argv0.as_deref() {
Some("mysql-dbadm") => mysql_dbadm::main().map(|result| Some(result)),
Some("mysql-useradm") => mysql_useradm::main().map(|result| Some(result)),
Some("mysql-dbadm") => mysql_dbadm::main().map(Some),
Some("mysql-useradm") => mysql_useradm::main().map(Some),
_ => Ok(None),
}
}

View File

@ -141,8 +141,7 @@ pub async fn create_mysql_connection_from_config(
) -> anyhow::Result<MySqlConnection> {
log_config(config);
let mut mysql_options = MySqlConnectOptions::new()
.database("mysql");
let mut mysql_options = MySqlConnectOptions::new().database("mysql");
if let Some(username) = &config.username {
mysql_options = mysql_options.username(username);
@ -168,6 +167,8 @@ pub async fn create_mysql_connection_from_config(
.await
{
Ok(connection) => connection.context("Failed to connect to the database"),
Err(_) => Err(anyhow!("Timed out after 2 seconds")).context("Failed to connect to the database"),
Err(_) => {
Err(anyhow!("Timed out after 2 seconds")).context("Failed to connect to the database")
}
}
}