mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
remove async dependencies
This commit is contained in:
parent
e2b0cd6b0d
commit
b187f36028
33 changed files with 120 additions and 129 deletions
|
|
@ -1,9 +1,9 @@
|
|||
use super::database::Row;
|
||||
use std::sync::RwLock;
|
||||
use std::cell::RefCell;
|
||||
|
||||
/// Reduce disk usage by cache Bookmarks index in memory
|
||||
pub struct Memory {
|
||||
index: RwLock<Vec<Row>>,
|
||||
index: RefCell<Vec<Row>>,
|
||||
}
|
||||
|
||||
impl Memory {
|
||||
|
|
@ -12,7 +12,7 @@ impl Memory {
|
|||
/// Create new `Self`
|
||||
pub fn init() -> Self {
|
||||
Self {
|
||||
index: RwLock::new(Vec::new()),
|
||||
index: RefCell::new(Vec::new()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ impl Memory {
|
|||
|
||||
/// Add new record
|
||||
pub fn push(&self, id: i64, query: String, is_default: bool) {
|
||||
self.index.write().unwrap().push(Row {
|
||||
self.index.borrow_mut().push(Row {
|
||||
id,
|
||||
query,
|
||||
is_default,
|
||||
|
|
@ -29,19 +29,19 @@ impl Memory {
|
|||
|
||||
/// Clear all records
|
||||
pub fn clear(&self) {
|
||||
self.index.write().unwrap().clear()
|
||||
self.index.borrow_mut().clear()
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
/// Get all records
|
||||
pub fn records(&self) -> Vec<Row> {
|
||||
self.index.read().unwrap().clone()
|
||||
self.index.borrow().clone()
|
||||
}
|
||||
|
||||
/// Get all records
|
||||
pub fn default(&self) -> Option<Row> {
|
||||
for record in self.index.read().unwrap().iter() {
|
||||
for record in self.index.borrow().iter() {
|
||||
if record.is_default {
|
||||
return Some(record.clone());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue