Fixing linter errors from clippy
This commit is contained in:
parent
d2efce722e
commit
a3c6655db1
@ -165,7 +165,7 @@ pub fn encrypt_value(value: &str, master_key: [u8; 32]) -> EncryptedValue {
|
|||||||
hmac.input(&output[..]);
|
hmac.input(&output[..]);
|
||||||
EncryptedValue {
|
EncryptedValue {
|
||||||
ciphertext: output,
|
ciphertext: output,
|
||||||
iv: iv,
|
iv,
|
||||||
mac: hmac.result(),
|
mac: hmac.result(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
src/db.rs
12
src/db.rs
@ -7,7 +7,7 @@ use std::error::Error;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
static DB_INIT_QUERY: &'static str = include_str!("init.sql");
|
static DB_INIT_QUERY: &str = include_str!("init.sql");
|
||||||
|
|
||||||
pub struct DbHandle {
|
pub struct DbHandle {
|
||||||
conn: Connection,
|
conn: Connection,
|
||||||
@ -50,13 +50,13 @@ impl DbHandle {
|
|||||||
pub fn new(db_path: &Option<String>) -> DbHandle {
|
pub fn new(db_path: &Option<String>) -> DbHandle {
|
||||||
let path: PathBuf = db_path
|
let path: PathBuf = db_path
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|path: &String| PathBuf::from(path))
|
.map(PathBuf::from)
|
||||||
.unwrap_or_else(|| dirs::home_dir().unwrap().join(".foil").to_path_buf());
|
.unwrap_or_else(|| dirs::home_dir().unwrap().join(".foil").to_path_buf());
|
||||||
let mut conn: Connection = Connection::open(path).unwrap();
|
let mut conn: Connection = Connection::open(path).unwrap();
|
||||||
let tx = conn.transaction().unwrap();
|
let tx = conn.transaction().unwrap();
|
||||||
tx.execute_batch(DB_INIT_QUERY).unwrap();
|
tx.execute_batch(DB_INIT_QUERY).unwrap();
|
||||||
tx.commit().unwrap();
|
tx.commit().unwrap();
|
||||||
DbHandle { conn: conn }
|
DbHandle { conn }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_namespace_id(
|
pub fn get_namespace_id(
|
||||||
@ -93,7 +93,7 @@ impl DbHandle {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let rowid: i64 = tx.last_insert_rowid();
|
let rowid: i64 = tx.last_insert_rowid();
|
||||||
let _ = tx.commit().unwrap();
|
tx.commit().unwrap();
|
||||||
Ok(rowid)
|
Ok(rowid)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ impl DbHandle {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _ = tx.commit().unwrap();
|
tx.commit().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_notes(&mut self, master_key: [u8; 32]) -> rusqlite::Result<Vec<Note>> {
|
pub fn read_notes(&mut self, master_key: [u8; 32]) -> rusqlite::Result<Vec<Note>> {
|
||||||
@ -215,7 +215,7 @@ impl DbHandle {
|
|||||||
.map(|option| option.map(|prop| prop.from_base64().unwrap()))
|
.map(|option| option.map(|prop| prop.from_base64().unwrap()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_db_property_bytes(&self, name: &str, value: &Vec<u8>) {
|
pub fn set_db_property_bytes(&self, name: &str, value: &[u8]) {
|
||||||
let b64value: String = value.to_base64(base64::STANDARD);
|
let b64value: String = value.to_base64(base64::STANDARD);
|
||||||
self.set_db_property(name, &b64value);
|
self.set_db_property(name, &b64value);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use std::iter::FromIterator;
|
|||||||
|
|
||||||
pub fn generate(spec: &str) {
|
pub fn generate(spec: &str) {
|
||||||
let (len, rest) = {
|
let (len, rest) = {
|
||||||
let mut separated = spec.splitn(2, ",");
|
let mut separated = spec.splitn(2, ',');
|
||||||
let len = separated.next().unwrap();
|
let len = separated.next().unwrap();
|
||||||
let rest = separated.next().unwrap();
|
let rest = separated.next().unwrap();
|
||||||
(len, rest)
|
(len, rest)
|
||||||
|
@ -16,7 +16,7 @@ pub mod crypt;
|
|||||||
pub mod db;
|
pub mod db;
|
||||||
pub mod generate;
|
pub mod generate;
|
||||||
|
|
||||||
static USAGE: &'static str = "
|
static USAGE: &str = "
|
||||||
foil
|
foil
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user