mirror of
https://github.com/davegallant/rfd-notify.git
synced 2025-08-09 18:02:28 +00:00
Add initial (#1)
This commit is contained in:
23
src/db.rs
Normal file
23
src/db.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
pub fn hash_exists(hash: &str) -> bool {
|
||||
let tree = sled::open("./deals_db").expect("open");
|
||||
let result = tree.get(hash);
|
||||
if result.is_err() {
|
||||
error!("{:?}", &result);
|
||||
}
|
||||
if result == Ok(None) {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub fn insert(hash: &str) {
|
||||
let tree = sled::open("./deals_db").expect("open");
|
||||
let result = tree.insert(&hash, "");
|
||||
if result.is_err() {
|
||||
error!("{:?}", &result);
|
||||
}
|
||||
let result = tree.flush();
|
||||
if result.is_err() {
|
||||
error!("{:?}", &result);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user