Expand description
Shared layout primitives for OxGraph graph and hypergraph crates.
Two responsibilities live here:
- Build-time (
BuildIndex,id_to_slot,slot_or_max,index_from_usize,build_offset_index): validate dense IDs against a known count, convertusizeslots back into a typed index width, and flatten per-bucket payloads into CSR-style(offsets, items)pairs. Used byoxgraph-graph-buildandoxgraph-hyper-build. - Read-time (
ZerocopyWord,OffsetIntegrityIssue,check_offsets_monotonic,check_value_range,check_offset_section): walk borrowed offset arrays at view-open time to enforce length matchescount + 1, first offset is zero, offsets non-decreasing, the final offset matches the value-array length, and every value fits in the dense bound. Used byoxgraph-csrandoxgraph-hyper-bcsr.
Helpers return small typed data enums (IdOutOfBounds,
OffsetOverflow, OffsetIntegrityIssue) instead of crate-specific
error types. Callers map the issue to their own typed error at the
boundary.
no_std + alloc (build-time primitives need Vec). No public domain
semantics. No dependency on any other oxgraph crate.
Enums§
- IdOut
OfBounds - Reasons an ID failed dense bounds validation.
- Offset
Integrity Issue - Reasons a borrowed offset or value array failed structural validation.
- Offset
Overflow - Reasons a
usizecould not be represented in a target index width during builder offset construction.
Traits§
- Build
Index - Unsigned dense ID width usable by graph and hypergraph builders.
- Zerocopy
Word - Borrowed offset or value word usable by offset-integrity primitives.
Functions§
- build_
offset_ index - Flattens per-bucket payloads into a
(offsets, items)pair. - check_
offset_ section - Validates one offset section against
expected_countrows and a backing values array of lengthvalue_len. - check_
offsets_ monotonic - Verifies
offsets[0] == 0and thatoffsetsis non-decreasing. - check_
value_ range - Verifies every value in
valuesis less thanbound. - id_
to_ slot - Validates that
id’susizerepresentation is less thancount. - index_
from_ usize - Converts a
usizevalue into the target index width. - slot_
or_ max - Returns
id’susizerepresentation, orusize::MAXwhen it does not fit inusizeon the current target.