J.A.R.V.I.S-rust/src-tauri/src/tauri_commands/db.rs

20 lines
358 B
Rust
Raw Normal View History

2023-04-27 00:28:36 +05:00
use crate::DB;
#[tauri::command]
pub fn db_read(key: &str) -> String {
2023-04-28 19:05:35 +05:00
if let Some(value) = DB.lock().unwrap().get::<String>(key) {
return value
2023-04-27 00:28:36 +05:00
}
2023-04-28 19:05:35 +05:00
String::from("")
2023-04-27 00:28:36 +05:00
}
#[tauri::command]
pub fn db_write(key: &str, val: &str) -> bool {
if let Ok(_) = DB.lock().unwrap().set(key, &val) {
true
} else {
false
}
}