Expand description
Shared layout primitives for OxGraph graph and hypergraph crates.
Three responsibilities live here:
- Index/word vocabulary (
LayoutIndex,LayoutWord,LayoutSnapshotWord,SnapshotWidth): the single sealed set of dense index widths, native/little-endian storage words, and the width-to-LE-word bijection shared by every layout and snapshot crate. CSR and BCSR add only thin section-kind-bearing sub-traits on top. - Build-time (
id_to_slot,slot_or_max,index_from_usize,build_offset_index,slice_to_le,map_offset_overflow): validate dense IDs against a known count, convertusizeslots back into a typed index width, flatten per-bucket payloads into CSR-style(offsets, items)pairs, and lower native index slices into explicit little-endian words. - Read-time (
OffsetIntegrityIssue,check_offsets_monotonic,check_value_range,check_offset_section,index_to_usize_validated,usize_to_index_validated): walk borrowed offset arrays at view-open time and convert already-validated indexes infallibly.
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.
LocalId is the one generic local-handle newtype every layout crate
aliases for its node/edge/vertex/hyperedge/incidence identities, and
IdSlice is the one slice-to-handle iterator they all reuse.
no_std + alloc (build-time primitives need Vec). No public domain
semantics. No dependency on any other oxgraph crate.
Structs§
- Edge
Axis - Relation axis for binary graphs (an edge).
- Hyperedge
Axis - Relation axis for hypergraphs (a hyperedge).
- IdSlice
- Iterator that maps a borrowed slice of
LayoutWords into axis-branded handles, recovering each logical index and wrapping it withId::from. - Incidence
Axis - Incidence axis (a participant / endpoint).
- LocalId
- A dense local handle: an axis-branded index value.
- Node
Axis - Element axis for binary graphs (a node).
- Vertex
Axis - Element axis for hypergraphs (a vertex).
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§
- Axis
- Marker for a local-handle axis (node, edge, vertex, hyperedge, incidence).
- Layout
Index - Unsigned dense ID width usable by graph and hypergraph layouts and builders.
- Layout
Snapshot Word - A little-endian storage word usable in persisted snapshot payloads.
- Layout
Word - A native-host or little-endian word carrying a typed dense
LayoutIndex. - Snapshot
Width - A persisted unsigned width with its little-endian storage word.
- 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. - index_
to_ usize_ validated - Converts an already-validated index into
usize. - map_
offset_ overflow - Maps an
OffsetOverflowinto a caller-chosen error viaon_overflow. - slice_
to_ le - Lowers a native index slice into explicit little-endian storage words.
- slot_
or_ max - Returns
id’susizerepresentation, orusize::MAXwhen it does not fit inusizeon the current target. - usize_
to_ index_ validated - Converts an already-validated
usizeslot into the target index width.