use crate::builder;
#[cfg(doc)]
use crate::prelude::*;
#[doc(inline)]
pub use crate::tree::RootDecodeError;
pub mod proof {
#[doc(inline)]
pub use crate::internal::{
path::PathDecodeError,
proof::{ProofDecodeError as DecodeError, VerifyError},
};
}
pub mod block {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
#[error("could not decode block root")]
pub struct RootDecodeError;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
#[error("block is full")]
#[non_exhaustive]
pub struct InsertError;
}
pub mod epoch {
use super::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
#[error("could not decode epoch root")]
pub struct RootDecodeError;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
pub enum InsertError {
#[error("epoch is full")]
#[non_exhaustive]
Full,
#[error("most recent block in epoch is full")]
#[non_exhaustive]
BlockFull,
}
#[derive(Debug, Clone, Error)]
#[error("epoch is full")]
#[non_exhaustive]
pub struct InsertBlockError(pub builder::block::Finalized);
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
pub enum InsertError {
#[error("tree is full")]
Full,
#[error("most recent epoch in tree is full")]
EpochFull,
#[error("most recent block in most recent epoch of tree is full")]
BlockFull,
}
#[derive(Debug, Clone, Error)]
pub enum InsertBlockError {
#[error("tree is full")]
#[non_exhaustive]
Full(builder::block::Finalized),
#[error("most recent epoch is full")]
#[non_exhaustive]
EpochFull(builder::block::Finalized),
}
impl From<InsertBlockError> for builder::block::Finalized {
fn from(error: InsertBlockError) -> Self {
match error {
InsertBlockError::Full(block) => block,
InsertBlockError::EpochFull(block) => block,
}
}
}
#[derive(Debug, Clone, Error)]
#[error("tree is full")]
#[non_exhaustive]
pub struct InsertEpochError(pub builder::epoch::Finalized);
impl From<InsertEpochError> for builder::epoch::Finalized {
fn from(error: InsertEpochError) -> Self {
error.0
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn insert_errors_sync_send() {
static_assertions::assert_impl_all!(InsertError: Sync, Send);
static_assertions::assert_impl_all!(InsertBlockError: Sync, Send);
static_assertions::assert_impl_all!(InsertEpochError: Sync, Send);
}
}