1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Low-level access to reading and writing chunk file based formats.
//!
//! See the [git documentation](https://github.com/git/git/blob/seen/Documentation/technical/chunk-format.txt) for details.
//!
//! ## Examples
//!
//! ```
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! 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");
//! # Ok(()) }
//! ```
/// An identifier to describe the kind of chunk, unique within a chunk file, typically in ASCII
pub type Id = ;
/// A special value denoting the end of the chunk file table of contents.
pub const SENTINEL: Id = ;
///
///