mod config;
pub use config::{LsmConfig, LsmDbConfig, PersistPolicy};
#[cfg(feature = "armour")]
mod handler;
mod iter;
pub use iter::LsmIter;
pub(crate) use iter::{LsmKeyIter, TryLsmIter, TryLsmKeyIter};
pub mod shard;
pub use shard::LsmShard;
mod tree;
pub use tree::LsmTree;
use crate::error::{DbError, DbResult};
pub(crate) fn map_fjall<T>(r: fjall::Result<T>) -> DbResult<T> {
r.map_err(|e| match e {
fjall::Error::Io(io_err) => DbError::Io(io_err),
other => DbError::Fjall(other.to_string()),
})
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn map_fjall_preserves_io_variant() {
let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "boom");
let kind = io_err.kind();
match map_fjall::<()>(Err(fjall::Error::Io(io_err))) {
Err(DbError::Io(e)) => assert_eq!(e.kind(), kind),
other => panic!("expected DbError::Io, got {other:?}"),
}
}
#[test]
fn map_fjall_flattens_other_variants_to_fjall_string() {
match map_fjall::<()>(Err(fjall::Error::Locked)) {
Err(DbError::Fjall(s)) => assert!(!s.is_empty()),
other => panic!("expected DbError::Fjall, got {other:?}"),
}
}
}