mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 21:34:27 +01:00
22 lines
507 B
Rust
22 lines
507 B
Rust
|
use std::path::Path;
|
||
|
use std::sync::Arc;
|
||
|
|
||
|
#[derive(Clone)]
|
||
|
pub struct Database(sled::Db);
|
||
|
|
||
|
impl Database {
|
||
|
pub fn start_default<P: AsRef<Path>>(path: P) -> sled::Result<Database> {
|
||
|
sled::Db::start_default(path).map(Database)
|
||
|
}
|
||
|
|
||
|
pub fn open_index(&self, name: &str) -> sled::Result<Index> {
|
||
|
let name = format!("index-{}", name);
|
||
|
let bytes = name.into_bytes();
|
||
|
|
||
|
self.0.open_tree(bytes).map(Index)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[derive(Debug, Clone)]
|
||
|
pub struct Index(Arc<sled::Tree>);
|