pub mod chunk;
pub mod header;
pub mod manifest;
use crate::error::SclsError;
pub use chunk::{Chunk, ChunkFooter, ChunkFormat, Entry};
pub use header::Header;
pub use manifest::{Manifest, NamespaceInfo, Summary};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum RecordType {
Header = 0x00,
Manifest = 0x01,
Chunk = 0x10,
Delta = 0x11,
Bloom = 0x20,
Index = 0x21,
Directory = 0x30,
Metadata = 0x31,
}
impl RecordType {
pub fn from_byte(byte: u8) -> Option<Self> {
match byte {
0x00 => Some(Self::Header),
0x01 => Some(Self::Manifest),
0x10 => Some(Self::Chunk),
0x11 => Some(Self::Delta),
0x20 => Some(Self::Bloom),
0x21 => Some(Self::Index),
0x30 => Some(Self::Directory),
0x31 => Some(Self::Metadata),
_ => None,
}
}
pub fn to_byte(self) -> u8 {
self as u8
}
}
impl TryFrom<u8> for RecordType {
type Error = SclsError;
fn try_from(byte: u8) -> Result<Self, Self::Error> {
Self::from_byte(byte).ok_or(SclsError::UnknownRecordType(byte))
}
}