husky/
lib.rs

1#![deny(missing_docs)]
2//! Husky is a library for creating databases like iterators.
3//! It is built around [sled].
4//!
5//! Take a look at the README to get started.
6//!
7//! Take a look at [ops] for a list of available operations.
8//!
9//! There are examples in the individual operations.
10//!
11//! Take a look at [traits] for a list of available traits.
12
13use anyhow::Result;
14use std::path::Path;
15
16mod helpers;
17mod macros;
18/// Various operations for transforming trees
19pub mod ops;
20mod structs;
21mod threads;
22/// Traits for viewing, watching and changing trees
23pub mod traits;
24/// Wrappers around sled
25pub mod wrappers;
26
27pub use {
28	ops::Operate,
29	structs::{material::Material, single::Single},
30	traits::{
31		auto_inc::AutoInc, change::Change, load::Load, store::Store, view::View, watch::Watch,
32	},
33  threads::wait_all,
34	wrappers::{batch::Batch, tree::Tree},
35};
36
37pub use database::Db;
38pub use sled::Config;
39use wrappers::*;
40
41/// Opens a database at the given path
42pub fn open(path: impl AsRef<Path>) -> Result<Db> {
43	let db = sled::open(path)?;
44	Ok(Db::from(db))
45}
46
47/// Opens a database in memory
48pub fn open_temp() -> Result<Db> {
49	let db = sled::Config::new().temporary(true).open()?;
50	Ok(Db::from(db))
51}
52
53#[cfg(test)]
54mod tests;