Fixes WASM builds

pull/171/head
Tpt 3 years ago
parent 0bd512a14c
commit dfe50cff11
  1. 19
      lib/src/storage/fallback_backend.rs

@ -1,3 +1,5 @@
//! TODO: This storage is dramatically naive.
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io::Result; use std::io::Result;
use std::sync::{Arc, Mutex, RwLock}; use std::sync::{Arc, Mutex, RwLock};
@ -16,22 +18,15 @@ impl Db {
}) })
} }
pub fn open_tree(&self, name: &'static str) -> Tree { pub fn open_tree(&self, name: &'static str) -> Result<Tree> {
self.trees.lock().unwrap().entry(name).or_default().clone() Ok(self.trees.lock().unwrap().entry(name).or_default().clone())
} }
pub fn flush(&self) -> Result<()> { pub fn flush(&self) -> Result<()> {
Ok(()) Ok(())
} }
pub fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>> {
self.default.get(key)
}
pub fn insert(&self, key: &[u8], value: &[u8]) -> Result<()> {
self.default.insert(key, value)
}
} }
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct Tree { pub struct Tree {
tree: Arc<RwLock<BTreeMap<Vec<u8>, Vec<u8>>>>, tree: Arc<RwLock<BTreeMap<Vec<u8>, Vec<u8>>>>,
@ -108,4 +103,8 @@ impl Iter {
pub fn next(&mut self) { pub fn next(&mut self) {
self.current = self.iter.next(); self.current = self.iter.next();
} }
pub fn status(&self) -> Result<()> {
Ok(())
}
} }

Loading…
Cancel
Save