use bytes::Bytes;
use crate::tree::TreeNode;
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Parent<H = hemera::Hash> {
pub node: TreeNode,
pub pair: (H, H),
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Leaf {
pub offset: u64,
pub data: Bytes,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum BaoContentItem<H = hemera::Hash> {
Parent(Parent<H>),
Leaf(Leaf),
}
impl<H> BaoContentItem<H> {
pub fn is_leaf(&self) -> bool {
matches!(self, Self::Leaf(_))
}
pub fn is_parent(&self) -> bool {
matches!(self, Self::Parent(_))
}
}