Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuckal777 committed Jan 18, 2023
1 parent 74f91bb commit f315199
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Client {
let response = crate::packet::parse(&mut self.stream)?;
if let Packet::Result { message, success } = response {
if !success {
eprintln!("Unlocking failed. It is likely that a wrong passphrase was entered. Received from daemon: {}", message);
eprintln!("Unlocking failed. It is likely that a wrong passphrase was entered. Received from daemon: {message}");
}
} else {
eprintln!("Received an unexpected return value from daemon.");
Expand All @@ -64,7 +64,7 @@ impl Client {
let response = crate::packet::parse(&mut self.stream)?;
if let Packet::Result { message, success } = response {
if !success {
eprintln!("Storing the credential failed. You may need to `nicator unlock`. Received from daemon: {}", message);
eprintln!("Storing the credential failed. You may need to `nicator unlock`. Received from daemon: {message}");
}
} else {
eprintln!("Received an unexpected return value from daemon.");
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{io::Read, path::PathBuf};

use clap::{crate_authors, crate_version, Arg, ArgMatches, Command, ArgAction};
use clap::{crate_authors, crate_version, Arg, ArgAction, ArgMatches, Command};
use client::Client;
use secstr::SecUtf8;
use thiserror::Error;
Expand Down Expand Up @@ -85,7 +85,7 @@ impl ProgramOptions {
return PathBuf::from(path);
}
let uid = nix::unistd::getuid();
let file_name = format!("/tmp/nicator-{}.sock", uid);
let file_name = format!("/tmp/nicator-{uid}.sock");
PathBuf::from(file_name)
}

Expand Down Expand Up @@ -162,7 +162,7 @@ pub fn run() -> Exit {
match options {
Ok(options) => perform_command(name, options),
Err(err) => {
eprintln!("Failed to determine arguments. {}", err);
eprintln!("Failed to determine arguments. {err}");
Exit::Failure
}
}
Expand Down Expand Up @@ -250,8 +250,8 @@ fn perform_unlock(options: &ProgramOptions) -> Exit {
}),
Err(err) => {
eprintln!(
"Failed to canonicalize store path {:?}: {}",
options.store, err
"Failed to canonicalize store path {:?}: {err}",
options.store
);
Exit::Failure
}
Expand Down Expand Up @@ -320,7 +320,7 @@ fn perform_export(options: &ProgramOptions) -> Exit {
}
}
Err(err) => {
eprintln!("Failed to export credentials: {}", err);
eprintln!("Failed to export credentials: {err}");
return Exit::Failure;
}
}
Expand Down Expand Up @@ -361,13 +361,13 @@ fn perform_import(options: &ProgramOptions) -> Exit {
match store.encrypt_at(&options.store, passphrase.unsecure()) {
Ok(_) => Exit::Success,
Err(err) => {
eprintln!("Failed to store imported credentials. {}", err);
eprintln!("Failed to store imported credentials. {err}");
Exit::Failure
}
}
}
Err(err) => {
eprintln!("Failed to import credentials: {}", err);
eprintln!("Failed to import credentials: {err}");
Exit::Failure
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ impl Daemon {
self.passphrase = Some(passphrase);
self.timeout = Duration::from_secs(timeout);
let response = Packet::Result {
message: "".to_string(),
message: String::new(),
success: true,
};
crate::packet::write(conn, &response)?;
}
Err(err) => {
let response = Packet::Result {
message: format!("{}", err),
message: format!("{err}"),
success: false,
};
crate::packet::write(conn, &response)?;
Expand All @@ -136,14 +136,14 @@ impl Daemon {
match result {
Ok(_) => {
let response = Packet::Result {
message: "".to_string(),
message: String::new(),
success: true,
};
crate::packet::write(conn, &response)?;
}
Err(err) => {
let response = Packet::Result {
message: format!("{}", err),
message: format!("{err}"),
success: false,
};
crate::packet::write(conn, &response)?;
Expand Down Expand Up @@ -190,7 +190,7 @@ impl Daemon {
}
Err(err) => {
let response = Packet::Result {
message: format!("{}", err),
message: format!("{err}"),
success: false,
};
crate::packet::write(conn, &response)?;
Expand Down Expand Up @@ -225,14 +225,14 @@ impl Daemon {
match result {
Ok(_) => {
let response = Packet::Result {
message: "".to_string(),
message: String::new(),
success: true,
};
crate::packet::write(conn, &response)?;
}
Err(err) => {
let response = Packet::Result {
message: format!("{}", err),
message: format!("{err}"),
success: false,
};
crate::packet::write(conn, &response)?;
Expand Down Expand Up @@ -264,7 +264,7 @@ pub fn launch<P: AsRef<Path>>(socket_path: P) -> Result<(), crate::Error> {
let mut daemon = Daemon::new(&socket_path)?;
match daemon.main_loop(socket_path.as_ref()) {
Ok(_) => println!("nicator server exiting"),
Err(err) => eprintln!("nicator server had an error: {}", err),
Err(err) => eprintln!("nicator server had an error: {err}"),
}
std::fs::remove_file(socket_path)?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Credential {
/// If the url is not valid.
pub fn from_url(url_str: &str) -> Result<Credential, url::ParseError> {
let url = url::Url::parse(url_str)?;
let port = url.port().map_or(String::new(), |p| format!(":{}", p));
let port = url.port().map_or(String::new(), |p| format!(":{p}"));
Ok(Credential {
host: url.host_str().unwrap_or("").to_string() + &port,
// leading slash is not required for git
Expand Down Expand Up @@ -255,7 +255,7 @@ mod tests {
super::Credential {
host: "host2".to_string(),
password: SecUtf8::from("pw2"),
path: "".to_string(),
path: String::new(),
protocol: "protocol2".to_string(),
username: "user2".to_string(),
},
Expand Down

0 comments on commit f315199

Please sign in to comment.