@@ -3,7 +3,6 @@ use std::borrow::Borrow;
|
||||
use heromodels_core::{Index, Model};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod fjall;
|
||||
pub mod hero;
|
||||
|
||||
pub trait Db {
|
||||
|
@@ -5,6 +5,7 @@ use serde::Deserialize;
|
||||
use std::{
|
||||
borrow::Borrow,
|
||||
collections::HashSet,
|
||||
path::PathBuf,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
@@ -18,11 +19,24 @@ pub struct OurDB {
|
||||
|
||||
impl OurDB {
|
||||
/// Create a new instance of ourdb
|
||||
pub fn new(index_db: tst::TST, data_db: ourdb::OurDB) -> Self {
|
||||
Self {
|
||||
pub fn new(path: impl Into<PathBuf>, reset: bool) -> Result<Self, tst::Error> {
|
||||
let mut base_path = path.into();
|
||||
let mut data_path = base_path.clone();
|
||||
base_path.push("index");
|
||||
data_path.push("data");
|
||||
|
||||
let data_db = ourdb::OurDB::new(ourdb::OurDBConfig {
|
||||
incremental_mode: false,
|
||||
path: data_path,
|
||||
file_size: None,
|
||||
keysize: None,
|
||||
reset: Some(reset),
|
||||
})?;
|
||||
let index_db = tst::TST::new(base_path.to_str().expect("Path is valid UTF-8"), reset)?;
|
||||
Ok(OurDB {
|
||||
index: Arc::new(Mutex::new(index_db)),
|
||||
data: Arc::new(Mutex::new(data_db)),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user