use alloc::{boxed::Box, string::String};
#[derive(Debug, thiserror::Error)]
pub enum StorageError {
#[error("backend error: {0}")]
Backend(#[from] Box<dyn core::error::Error + Send + Sync + 'static>),
#[error("invalid key length: expected {expected} bytes, found {found}")]
BadKeyLen { expected: usize, found: usize },
#[error(
"invalid subtree key length at depth {depth}: expected {expected} bytes, found {found}"
)]
BadSubtreeKeyLen { depth: u8, expected: usize, found: usize },
#[error("invalid value length for {what}: expected {expected} bytes, found {found}")]
BadValueLen {
what: &'static str,
expected: usize,
found: usize,
},
#[error("leaf operation failed")]
Leaf(#[from] crate::merkle::smt::SmtLeafError),
#[error("failed to decode subtree")]
Subtree(#[from] crate::merkle::smt::SubtreeError),
#[error("operation not supported: {0}")]
Unsupported(String),
#[error("failed to decode value bytes")]
Value(#[from] crate::utils::DeserializationError),
}