Skip to main content

Module geometry

Module geometry 

Source
Expand description

Geometry value types for the document model.

No floats anywhere: coordinates are integers (GridPoint) or fixed-point (FracVal), so every value has exactly one encoding and the bytes the change hash covers are deterministic.

Structs§

FracVal
An f32 quantized to units of 2⁻²⁴ (truncated toward zero), stored as i64. NOTE: f32 -> FracVal on NaN saturates to 0 (Rust as cast). Reject NaN at command construction (debug_assert) rather than relying on saturation.
GridPoint
GridRect
Atomic wherever it appears — one register holds the whole rect.
GridSize
GridVec
A grid-space delta. Deliberately not serializable: deltas never cross the wire — commits carry the absolute values a delta produced.
PinSlot
Where a pin sits on its block-as-child: an edge and a slot index (slots, not cells — the pitch is the editor’s concern). Atomic: a slot is one author’s intent, and split registers could merge to an edge one write chose and an offset another did.
RawGridPoint 🔒
Mirrors GridPoint so try_from has an unchecked type to decode into first — serde’s price for a validating decode.
RawGridSize 🔒
RawPinSlot 🔒
ScreenPoint
ScreenRect
Atomic (same reasoning as GridRect). Default = empty rect (meaningful zero).
ScreenSize
Waypoint
The lock rides inside the atomic waypoints value: a polyline with its locks is one author’s coherent intent.

Enums§

OutOfExtent

Constants§

GRID_LIMIT
The document extent, in grid cells: two of them sum far inside i32, so no rect accessor can overflow a value a decoder accepted. Enforced at the decode boundary, where “bounded by the document extent” stops being true because the payload came from a stranger. Refused, never clamped — clamping relocates geometry instead of reporting a bad payload. Authoring must respect it too, or it writes commits it cannot read back.