Expand description
Low-level access to reading and writing chunk file based formats.
See the git documentation for details.
§Examples
use std::io::Write;
let mut index = gix_chunk::file::Index::for_writing();
index.plan_chunk(*b"OIDF", 4);
index.plan_chunk(*b"DATA", 3);
let mut out = index.into_write(Vec::new(), 0)?;
while let Some(kind) = out.next_chunk() {
match kind {
[b'O', b'I', b'D', b'F'] => out.write_all(b"abcd")?,
[b'D', b'A', b'T', b'A'] => out.write_all(b"xyz")?,
_ => unreachable!("planned chunks are known"),
}
}
let data = out.into_inner();
let decoded = gix_chunk::file::Index::from_bytes(&data, 0, 2)?;
assert_eq!(decoded.data_by_id(&data, *b"OIDF")?, b"abcd");
assert_eq!(decoded.data_by_id(&data, *b"DATA")?, b"xyz");Modules§
Constants§
- SENTINEL
- A special value denoting the end of the chunk file table of contents.
Type Aliases§
- Id
- An identifier to describe the kind of chunk, unique within a chunk file, typically in ASCII