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