use crate::{blake3, BaoTree, BlockSize, ByteNum, TreeNode};
use bytes::Bytes;
mod error;
pub use error::*;
use self::outboard::PostOrderMemOutboard;
#[cfg(feature = "tokio_fsm")]
pub mod fsm;
pub mod outboard;
pub mod sync;
#[derive(Debug)]
pub struct Header {
pub size: ByteNum,
}
#[derive(Debug)]
pub struct Parent {
pub node: TreeNode,
pub pair: (blake3::Hash, blake3::Hash),
}
#[derive(Debug)]
pub struct Leaf {
pub offset: ByteNum,
pub data: Bytes,
}
pub fn outboard_size(size: u64, block_size: BlockSize) -> u64 {
BaoTree::outboard_size(ByteNum(size), block_size).0
}
pub fn encoded_size(size: u64, block_size: BlockSize) -> u64 {
outboard_size(size, block_size) + size
}
pub fn outboard(input: impl AsRef<[u8]>, block_size: BlockSize) -> (Vec<u8>, blake3::Hash) {
let outboard = PostOrderMemOutboard::create(input, block_size).flip();
let hash = *outboard.hash();
(outboard.into_inner_with_prefix(), hash)
}