Expand description
Per-collection document identifier — Id(NonZeroU64).
See docs/format.md § Id allocation for the on-disk contract.
Id is the public identifier type every collection hands out for
its documents. The newtype encoding pins three invariants:
- Zero is reserved as the sentinel “no id” value —
Id::try_new(0)returnsNone. This makesOption<Id>the same size asIdand gives the freelist / catalog primitives an unambiguous “missing” marker. - Allocation is per-collection monotonic. Two collections can
independently hand out
Id(1), Id(2), ...without interference; the catalog row for each collection carries its ownnext_idwatermark. - The serde representation of
Idis its innerNonZeroU64, so anIdcan appear in userDocumenttypes verbatim and round- trip through postcard.
§Power-of-ten posture
- Rule 5.
NonZeroU64is the type-level invariant; thetry_newconstructor is the runtime boundary. - Rule 7. Wraparound at
u64::MAXreturnsError::IdSpaceExhausted— never a panic.
Structs§
- Id
- Per-collection document identifier.
Functions§
- bump_
next_ id - Allocator shim used by the catalog to mint the next
Idin a collection.