pub mod database;
pub mod hasher;
pub mod tree;
use std::fmt::{Debug, Display};
pub use database::*;
pub use hasher::*;
pub use tree::MerkleTree;
pub type DBKey = [u8; 8];
pub type Value = Vec<u8>;
#[derive(Debug)]
pub enum TreeErrorKind {
MerkleTreeIsFull,
InvalidKey,
IndexOutOfBounds,
CustomError(String),
}
#[derive(Debug)]
pub enum DatabaseErrorKind {
CannotLoadDatabase,
DatabaseExists,
CustomError(String),
}
#[derive(Debug)]
pub enum PmtreeErrorKind {
DatabaseError(DatabaseErrorKind),
TreeError(TreeErrorKind),
CustomError(String),
}
impl Display for PmtreeErrorKind {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
PmtreeErrorKind::DatabaseError(e) => write!(f, "Database error: {e:?}"),
PmtreeErrorKind::TreeError(e) => write!(f, "Tree error: {e:?}"),
PmtreeErrorKind::CustomError(e) => write!(f, "Custom error: {e:?}"),
}
}
}
impl std::error::Error for PmtreeErrorKind {}
pub type PmtreeResult<T> = std::result::Result<T, PmtreeErrorKind>;