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
//! Lowercase hex for digest bytes.
//!
//! Exists because `sha2` 0.11 (via `digest` 0.11 and `hybrid-array`) returns
//! a plain `Array` from `finalize`/`digest`, and that type no longer
//! implements `LowerHex` the way `GenericArray` did in 0.10. Every
//! `format!("{:x}", ...)` on a hash therefore stopped compiling.
//!
//! One helper rather than an inline `fold` at each of the four call sites:
//! these strings are content-addressing keys and graph fingerprints that get
//! compared against values already written to disk, so all four must agree
//! on the encoding exactly. A single function makes that agreement
//! structural instead of a thing four separate lines have to keep getting
//! right.
//!
//! Deliberately not a new dependency. The whole job is two lines, and a
//! digest is the only thing this codebase ever hex-encodes.
/// Encode `bytes` as lowercase hex, two characters per byte.
///
/// Byte-for-byte identical to what `format!("{:x}", digest)` produced under
/// `sha2` 0.10, which matters: existing blob filenames, catalog index
/// entries, and recorded graph fingerprints were all written with the old
/// formatting, and a change here would silently invalidate every one of
/// them.