Skip to content

Commit cbd6413

Browse files
author
replydev
committed
Some variables can be no mutable
1 parent b9f46ec commit cbd6413

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/database_loader.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ impl OTPElement {
6767
}
6868

6969
pub fn read_from_file() -> Result<Vec<OTPElement>,String>{
70-
let mut encrypted_contents = read_to_string(&get_db_path()).unwrap();
70+
let encrypted_contents = read_to_string(&get_db_path()).unwrap();
7171
//rust close files at the end of the function
72-
let contents = cryptograpy::decrypt_string(&mut encrypted_contents, &cryptograpy::prompt_for_passwords("Password: "));
72+
let contents = cryptograpy::decrypt_string(&encrypted_contents, &cryptograpy::prompt_for_passwords("Password: "));
7373
match contents {
7474
Ok(contents) => {
7575
let vector: Vec<OTPElement> = serde_json::from_str(&contents).unwrap();
@@ -172,8 +172,8 @@ pub fn export_database() -> Result<String, String> {
172172
let mut exported_path = utils::get_home_folder().to_str().unwrap().to_string();
173173
exported_path.push_str("/exported.cotp");
174174
let mut file = File::create(&exported_path).expect("Cannot create file");
175-
let mut encrypted_contents = read_to_string(&get_db_path()).unwrap();
176-
let contents = cryptograpy::decrypt_string(&mut encrypted_contents, &cryptograpy::prompt_for_passwords("Password: "));
175+
let encrypted_contents = read_to_string(&get_db_path()).unwrap();
176+
let contents = cryptograpy::decrypt_string(&encrypted_contents, &cryptograpy::prompt_for_passwords("Password: "));
177177
match contents {
178178
Ok(contents) => {
179179
file.write_all(contents.as_bytes()).expect("Failed to write contents");
@@ -191,7 +191,7 @@ pub fn overwrite_database(elements: Vec<OTPElement>){
191191
}
192192

193193
pub fn overwrite_database_json(json: &str){
194-
let encrypted = cryptograpy::encrypt_string(&mut json.to_string(), &cryptograpy::prompt_for_passwords("Insert password for database encryption: "));
194+
let encrypted = cryptograpy::encrypt_string(json.to_string(), &cryptograpy::prompt_for_passwords("Insert password for database encryption: "));
195195
utils::write_to_file(&encrypted, &mut File::create(utils::get_db_path()).expect("Failed to open file"));
196196
}
197197

0 commit comments

Comments
 (0)