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
//! Fixed-width little-endian on-disk `u64` codec — the crate's one place for
//! reading and writing 8-byte integer fields, by hand into a buffer or straight
//! from a [`BStack`].
//!
//! Every on-disk multi-byte integer (`bstack`'s own format, refcounts, offsets,
//! `ctrl` back-pointers, `Foreign` targets, linked-structure next/prev/child
//! slots) is little-endian; these helpers centralize that convention instead of
//! repeating `to_le_bytes` / `from_le_bytes` at every image builder and reader.
use io;
use BStack;
/// Write `val` as a little-endian `u64` at byte offset `off` in `buf`.
///
/// The one place the crate builds on-disk integer fields by hand, instead of
/// repeating `copy_from_slice(&x.to_le_bytes())` at every image builder.
/// Read a little-endian `u64` from the first 8 bytes of `buf`.
///
/// This centralizes the crate's fixed-width on-disk `u64` decode pattern.
/// Read a little-endian `u64` directly from the block at `off` — the crate's
/// fixed-width on-disk `u64` load (an 8-byte `get_into` fed through [`get_u64`]).
/// Every on-disk pointer/count field (`ctrl` back-pointers, `Foreign` targets,
/// linked-structure offsets, refcounts) is decoded through this.