1#[cfg(feature = "compression")]
3pub use hff_core::read::decompress;
4
5pub use hff_core;
7
8pub use hff_core::{
10 read::{ChunkView, Hff, TableView},
11 utilities,
12 write::{chunk, hff, table, ChunkDesc, DataSource, HffDesc, TableBuilder},
13 ByteOrder, ChunkCache, ContentInfo, Ecc, Error, IdType, Result, Version, BE, LE, NE, OP,
14};
15
16mod read;
17pub use read::*;
18
19#[cfg(test)]
20mod tests {
21 use super::*;
22
23 #[async_std::test]
24 async fn tests() -> Result<()> {
25 let content = hff([
26 table((Ecc::new("Prime"), Ecc::new("Second")))
27 .metadata("Each table can have metadata.")?
29 .chunks([chunk(
31 (Ecc::new("AChunk"), Ecc::INVALID),
32 "Each table can have 0..n chunks of data.",
33 )?])
34 .children([table((Ecc::new("Child1"), Ecc::INVALID))
36 .metadata("Unique to this table.")?
37 .chunks([chunk(
38 (Ecc::new("ThisFile"), Ecc::new("Copy")),
39 "More stuff to put in the chunk.",
40 )?])]),
41 table((Ecc::new("Child2"), Ecc::INVALID)),
43 ]);
44
45 let mut buffer = vec![];
47 use hff_std::Writer;
48 content.write::<hff_core::NE>(IdType::Ecc2, "Test", &mut buffer)?;
49
50 use async_std::io::Cursor;
52 let reader: Box<dyn ReadSeek> = Box::new(Cursor::new(buffer.into_boxed_slice()));
53
54 let hff = open(reader).await?;
56
57 for (depth, table) in hff.depth_first() {
58 println!(
60 "{}: {:?} ({})",
61 depth,
62 table.identifier(),
63 std::str::from_utf8(hff.read(&table).await?.as_slice()).unwrap()
64 );
65
66 for chunk in table.chunks() {
68 println!(
69 "{}",
70 std::str::from_utf8(hff.read(&chunk).await?.as_slice()).unwrap()
71 );
72 }
73 }
74
75 Ok(())
76 }
77}