Skip to main content

Crate oxgraph_layout_util

Crate oxgraph_layout_util 

Source
Expand description

Shared layout primitives for OxGraph graph and hypergraph crates.

Three responsibilities live here:

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§

EdgeAxis
Relation axis for binary graphs (an edge).
HyperedgeAxis
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 with Id::from.
IncidenceAxis
Incidence axis (a participant / endpoint).
LocalId
A dense local handle: an axis-branded index value.
NodeAxis
Element axis for binary graphs (a node).
VertexAxis
Element axis for hypergraphs (a vertex).

Enums§

IdOutOfBounds
Reasons an ID failed dense bounds validation.
OffsetIntegrityIssue
Reasons a borrowed offset or value array failed structural validation.
OffsetOverflow
Reasons a usize could 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).
LayoutIndex
Unsigned dense ID width usable by graph and hypergraph layouts and builders.
LayoutSnapshotWord
A little-endian storage word usable in persisted snapshot payloads.
LayoutWord
A native-host or little-endian word carrying a typed dense LayoutIndex.
SnapshotWidth
A persisted unsigned width with its little-endian storage word.
ZerocopyWord
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_count rows and a backing values array of length value_len.
check_offsets_monotonic
Verifies offsets[0] == 0 and that offsets is non-decreasing.
check_value_range
Verifies every value in values is less than bound.
id_to_slot
Validates that id’s usize representation is less than count.
index_from_usize
Converts a usize value into the target index width.
index_to_usize_validated
Converts an already-validated index into usize.
map_offset_overflow
Maps an OffsetOverflow into a caller-chosen error via on_overflow.
slice_to_le
Lowers a native index slice into explicit little-endian storage words.
slot_or_max
Returns id’s usize representation, or usize::MAX when it does not fit in usize on the current target.
usize_to_index_validated
Converts an already-validated usize slot into the target index width.