Expand description
Topology-agnostic byte-level snapshot container.
oxgraph-snapshot defines a sectioned, zero-copy checkpoint format that
can validate, package, and read immutable topology snapshots without
knowing whether their contents are graphs, hypergraphs, or anything
else. Section semantics belong to upper layers (oxgraph-csr,
oxgraph-graph, oxgraph-hyper); the container only validates and
exposes byte-aligned section payloads.
§Format overview
Every snapshot consists of a fixed HEADER_SIZE-byte header, a
SECTION_ENTRY_SIZE-byte entry per section, and a payload region
whose offsets and lengths are recorded in the entries. All multi-byte
integer fields are little-endian and stored unaligned, so snapshots can
be borrowed from any byte slice — Vec<u8>, mmap’d files, sub-slices —
without an alignment requirement on the base pointer.
The container mandates two integrity invariants. Every section entry carries a
CRC-32C over its payload bytes and the header carries a CRC-32C over the
section-table bytes; the crate is no_std and bundles no CRC
implementation, so writers and the checked/verify read paths take a
Checksum32 function (e.g. oxgraph_layout_util::crc32c_append).
Section kinds must be strictly ascending across the table, which makes
the table duplicate-free and Snapshot::section a binary search.
Section payloads are exposed as byte slices via Section::bytes; the
Section::try_as_slice helper checks the actual payload pointer’s
alignment against align_of::<T>() so consumers can reinterpret
&[u8] as &[T] only when it is safe to do so.
§Cargo features
- default: reader-only API;
no_std, no allocation. alloc: enables [SnapshotWriter], the owning write-through encoder that returns encodedVec<u8>bytes.std: reserved for future mmap helpers; no effect beyond activatingalloc.
§Stability
The bytes are intentionally not yet promised as a stable ABI: a snapshot whose format major does not match this library is rejected at open. Format minor bumps will preserve backward read compatibility once they ship.
Modules§
- kinds
- Section-kind band allocation registry: the single documented authority for
who owns which range of the opaque
u32kind namespace.
Structs§
- Header
Only Snapshot - Header-only handle to a snapshot’s bytes.
- Pending
Section - Description of one section to include in a snapshot.
- Section
- Borrowed view of one validated section in a snapshot.
- Section
Iter - Iterator over a snapshot’s validated sections.
- Section
Kind - Typed wrapper over a section’s opaque
u32kind tag. - Snapshot
- Validated, borrowed handle to a snapshot’s bytes and section table.
- Snapshot
Plan - Validated plan that can compute its encoded length and write itself.
Enums§
- Plan
Error - Error returned by snapshot writers.
- Section
Bind Error - Error returned when binding a width-typed section by kind and version.
- Section
View Error - Error returned when borrowing a section payload as a typed slice fails.
- Snapshot
Error - Snapshot container validation error.
- Validation
Level - Validation depth applied at snapshot open time.
Constants§
- CRC32C_
CHECK_ INPUT - Standard CRC-32C check-vector input (the ASCII digits
123456789). - CRC32C_
CHECK_ VALUE - Standard CRC-32C check-vector result:
crc32c(0, b"123456789"). - FORMAT_
MAGIC - Magic bytes identifying the topology snapshot container format.
- FORMAT_
MAJOR - Format major version this library reads and writes.
- FORMAT_
MINOR - Format minor version written by this library’s builder.
- HEADER_
SIZE - Size of the snapshot header in bytes.
- MAX_
ALIGNMENT_ LOG2 - Maximum permitted
alignment_log2value (2^12 = 4 KiB, page-friendly). - MAX_
SECTION_ COUNT - Maximum permitted section count for v2 snapshots.
- MAX_
SUPPORTED_ MINOR - Highest format minor version this library can read.
- SECTION_
ENTRY_ SIZE - Size of one section table entry in bytes.
Functions§
- patch_
section_ crc - Recomputes and patches one section’s entry CRC-32C (and the header’s
table_crc32c, which covers that entry) in already-encoded snapshot bytes.
Type Aliases§
- Checksum32
- Continuation-style CRC-32C (Castagnoli, polynomial
0x1EDC_6F41) fold.