#[cfg(feature = "compression")]
pub use hff_core::read::decompress;
pub use hff_core;
pub use hff_core::{
read::{ChunkView, Hff, TableView},
utilities,
write::{chunk, hff, table, ChunkDesc, DataSource, HffDesc, TableBuilder},
ByteOrder, ChunkCache, ContentInfo, Ecc, Error, IdType, Result, Version, BE, LE, NE, OP,
};
mod read;
pub use read::*;
#[cfg(test)]
mod tests {
use super::*;
#[async_std::test]
async fn tests() -> Result<()> {
let content = hff([
table((Ecc::new("Prime"), Ecc::new("Second")))
.metadata("Each table can have metadata.")?
.chunks([chunk(
(Ecc::new("AChunk"), Ecc::INVALID),
"Each table can have 0..n chunks of data.",
)?])
.children([table((Ecc::new("Child1"), Ecc::INVALID))
.metadata("Unique to this table.")?
.chunks([chunk(
(Ecc::new("ThisFile"), Ecc::new("Copy")),
"More stuff to put in the chunk.",
)?])]),
table((Ecc::new("Child2"), Ecc::INVALID)),
]);
let mut buffer = vec![];
use hff_std::Writer;
content.write::<hff_core::NE>(IdType::Ecc2, "Test", &mut buffer)?;
use async_std::io::Cursor;
let reader: Box<dyn ReadSeek> = Box::new(Cursor::new(buffer.into_boxed_slice()));
let hff = open(reader).await?;
for (depth, table) in hff.depth_first() {
println!(
"{}: {:?} ({})",
depth,
table.identifier(),
std::str::from_utf8(hff.read(&table).await?.as_slice()).unwrap()
);
for chunk in table.chunks() {
println!(
"{}",
std::str::from_utf8(hff.read(&chunk).await?.as_slice()).unwrap()
);
}
}
Ok(())
}
}