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.
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 [SnapshotBuilder], an owning builder that returns an encodedVec<u8>.std: reserved for future mmap helpers; no effect in v1 beyond activatingalloc.
§Stability
v1.0 is the first topology-agnostic format major; the bytes are intentionally not yet promised as a stable ABI. Format minor bumps will preserve backward read compatibility once they ship.
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.
- 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
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§
- 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 v1 snapshots.
- MAX_
SUPPORTED_ MINOR - Highest format minor version this library can read.
- SECTION_
ENTRY_ SIZE - Size of one section table entry in bytes.