From d5cb25cc6a5821b41f49c9aabe548b610ba2f9b6 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Wed, 25 Oct 2023 07:21:27 +0800 Subject: [PATCH] feat: fix clippy --- src/cmd_encrypt.rs | 6 ++++-- src/crypto_cryptor.rs | 2 +- src/util_piv.rs | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cmd_encrypt.rs b/src/cmd_encrypt.rs index 257eec3..cbe3488 100644 --- a/src/cmd_encrypt.rs +++ b/src/cmd_encrypt.rs @@ -184,10 +184,11 @@ fn encrypt_single(path: &PathBuf, envelops: &[&TinyEncryptConfigEnvelop], cmd_en let _ = util_enc_file::write_tiny_encrypt_meta(&mut file_out, &encrypt_meta, compress_meta)?; let compress_desc = iff!(cmd_encrypt.compress, " [with compress]", ""); + let compress_level = iff!(cmd_encrypt.compress, &cmd_encrypt.compress_level, &None); let start = Instant::now(); encrypt_file( &mut file_in, file_metadata.len(), &mut file_out, cryptor, - &key.0, &nonce.0, cmd_encrypt.compress, &cmd_encrypt.compress_level, + &key.0, &nonce.0, compress_level, )?; drop(file_out); let encrypt_duration = start.elapsed(); @@ -220,7 +221,8 @@ fn process_compatible_with_1_0(mut encrypt_meta: TinyEncryptMeta) -> XResult) -> XResult { + key: &[u8], nonce: &[u8], compress_level: &Option) -> XResult { + let compress = compress_level.is_some(); let mut total_len = 0_u64; let mut write_len = 0_u64; let mut buffer = [0u8; 1024 * 8]; diff --git a/src/crypto_cryptor.rs b/src/crypto_cryptor.rs index 9e34ed6..33ec568 100644 --- a/src/crypto_cryptor.rs +++ b/src/crypto_cryptor.rs @@ -16,7 +16,7 @@ impl Cryptor { match algorithm { "aes256-gcm" | consts::TINY_ENC_AES_GCM => Ok(Cryptor::Aes256Gcm), "chacha20-poly1305" | consts::TINY_ENC_CHACHA20_POLY1305 => Ok(Cryptor::ChaCha20Poly1305), - _ => simple_error!("Unknown altorighm: {}",algorithm), + _ => simple_error!("Unknown algorithm: {}",algorithm), } } diff --git a/src/util_piv.rs b/src/util_piv.rs index 626432a..5a04e10 100644 --- a/src/util_piv.rs +++ b/src/util_piv.rs @@ -1,7 +1,7 @@ use std::io; use std::io::Write; -use rust_util::{information, simple_error, XResult}; +use rust_util::{information, print_ex, simple_error, XResult}; use yubikey::piv::{RetiredSlotId, SlotId}; use crate::config::TinyEncryptConfig; @@ -16,7 +16,7 @@ pub fn read_piv_slot(config: &Option, kid: &str, slot: &Optio return Ok(first_arg.to_string()); } } - print!("Input slot(eg 82, 83 ...): "); + print_ex!("Input slot(eg 82, 83 ...): "); io::stdout().flush().ok(); let mut buff = String::new(); let _ = io::stdin().read_line(&mut buff).expect("Read line from stdin");