gmarche-rs/src/db.rs

20 lines
313 B
Rust
Raw Normal View History

2020-12-17 12:12:21 +01:00
use sled::Tree;
2020-10-26 23:43:18 +01:00
use std::path::Path;
2020-12-08 11:05:59 +01:00
const DB_DIR: &str = "db";
2020-10-26 23:43:18 +01:00
2020-12-08 11:05:59 +01:00
const DB_NAME_ADS: &str = "ads";
2020-12-17 12:12:21 +01:00
#[derive(Clone)]
2020-10-26 23:43:18 +01:00
pub struct Dbs {
pub ads: Tree,
2020-10-26 23:43:18 +01:00
}
pub fn load_dbs(path: &Path) -> Dbs {
let db = sled::open(path.join(DB_DIR)).expect("Cannot open db");
Dbs {
ads: db.open_tree(DB_NAME_ADS).unwrap(),
}
2020-10-26 23:43:18 +01:00
}