chore: cargo clippy

pull/144/head
sigoden 2022-11-10 15:38:35 +08:00
parent dbf2de9cb9
commit bd07783cde
4 changed files with 12 additions and 12 deletions

View File

@ -216,7 +216,7 @@ impl AuthMethod {
let digest_vals = to_headermap(digest_value).ok()?; let digest_vals = to_headermap(digest_value).ok()?;
digest_vals digest_vals
.get(b"username".as_ref()) .get(b"username".as_ref())
.and_then(|b| std::str::from_utf8(*b).ok()) .and_then(|b| std::str::from_utf8(b).ok())
.map(|v| v.to_string()) .map(|v| v.to_string())
} }
} }
@ -255,7 +255,7 @@ impl AuthMethod {
if let (Some(username), Some(nonce), Some(user_response)) = ( if let (Some(username), Some(nonce), Some(user_response)) = (
digest_vals digest_vals
.get(b"username".as_ref()) .get(b"username".as_ref())
.and_then(|b| std::str::from_utf8(*b).ok()), .and_then(|b| std::str::from_utf8(b).ok()),
digest_vals.get(b"nonce".as_ref()), digest_vals.get(b"nonce".as_ref()),
digest_vals.get(b"response".as_ref()), digest_vals.get(b"response".as_ref()),
) { ) {
@ -278,7 +278,7 @@ impl AuthMethod {
if qop == &b"auth".as_ref() || qop == &b"auth-int".as_ref() { if qop == &b"auth".as_ref() || qop == &b"auth-int".as_ref() {
correct_response = Some({ correct_response = Some({
let mut c = Context::new(); let mut c = Context::new();
c.consume(&auth_pass); c.consume(auth_pass);
c.consume(b":"); c.consume(b":");
c.consume(nonce); c.consume(nonce);
c.consume(b":"); c.consume(b":");
@ -301,7 +301,7 @@ impl AuthMethod {
Some(r) => r, Some(r) => r,
None => { None => {
let mut c = Context::new(); let mut c = Context::new();
c.consume(&auth_pass); c.consume(auth_pass);
c.consume(b":"); c.consume(b":");
c.consume(nonce); c.consume(nonce);
c.consume(b":"); c.consume(b":");

View File

@ -593,7 +593,7 @@ impl Server {
None None
}; };
if let Some(mime) = mime_guess::from_path(&path).first() { if let Some(mime) = mime_guess::from_path(path).first() {
res.headers_mut().typed_insert(ContentType::from(mime)); res.headers_mut().typed_insert(ContentType::from(mime));
} else { } else {
res.headers_mut().insert( res.headers_mut().insert(
@ -902,7 +902,7 @@ impl Server {
Some(path) => path, Some(path) => path,
None => return None, None => return None,
}; };
Some(self.args.path.join(&stripped_path)) Some(self.args.path.join(stripped_path))
} }
fn strip_path_prefix<'a, P: AsRef<Path>>(&self, path: &'a P) -> Option<&'a Path> { fn strip_path_prefix<'a, P: AsRef<Path>>(&self, path: &'a P) -> Option<&'a Path> {

View File

@ -125,8 +125,8 @@ impl Accept for TlsAcceptor {
// Load public certificate from file. // Load public certificate from file.
pub fn load_certs(filename: &str) -> Result<Vec<Certificate>, Box<dyn std::error::Error>> { pub fn load_certs(filename: &str) -> Result<Vec<Certificate>, Box<dyn std::error::Error>> {
// Open certificate file. // Open certificate file.
let cert_file = fs::File::open(&filename) let cert_file =
.map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?; fs::File::open(filename).map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?;
let mut reader = io::BufReader::new(cert_file); let mut reader = io::BufReader::new(cert_file);
// Load and return certificate. // Load and return certificate.
@ -139,8 +139,8 @@ pub fn load_certs(filename: &str) -> Result<Vec<Certificate>, Box<dyn std::error
// Load private key from file. // Load private key from file.
pub fn load_private_key(filename: &str) -> Result<PrivateKey, Box<dyn std::error::Error>> { pub fn load_private_key(filename: &str) -> Result<PrivateKey, Box<dyn std::error::Error>> {
let key_file = fs::File::open(&filename) let key_file =
.map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?; fs::File::open(filename).map_err(|e| format!("Failed to access `{}`, {}", &filename, e))?;
let mut reader = io::BufReader::new(key_file); let mut reader = io::BufReader::new(key_file);
// Load and return a single private key. // Load and return a single private key.

View File

@ -34,7 +34,7 @@ fn tls_works(#[case] server: TestServer) -> Result<(), Error> {
#[rstest] #[rstest]
fn wrong_path_cert() -> Result<(), Error> { fn wrong_path_cert() -> Result<(), Error> {
Command::cargo_bin("dufs")? Command::cargo_bin("dufs")?
.args(&["--tls-cert", "wrong", "--tls-key", "tests/data/key.pem"]) .args(["--tls-cert", "wrong", "--tls-key", "tests/data/key.pem"])
.assert() .assert()
.failure() .failure()
.stderr(contains("error: Failed to access `wrong`")); .stderr(contains("error: Failed to access `wrong`"));
@ -46,7 +46,7 @@ fn wrong_path_cert() -> Result<(), Error> {
#[rstest] #[rstest]
fn wrong_path_key() -> Result<(), Error> { fn wrong_path_key() -> Result<(), Error> {
Command::cargo_bin("dufs")? Command::cargo_bin("dufs")?
.args(&["--tls-cert", "tests/data/cert.pem", "--tls-key", "wrong"]) .args(["--tls-cert", "tests/data/cert.pem", "--tls-key", "wrong"])
.assert() .assert()
.failure() .failure()
.stderr(contains("error: Failed to access `wrong`")); .stderr(contains("error: Failed to access `wrong`"));