Skip to main content

Module id

Module id 

Source
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:

  1. Zero is reserved as the sentinel “no id” value — Id::try_new(0) returns None. This makes Option<Id> the same size as Id and gives the freelist / catalog primitives an unambiguous “missing” marker.
  2. 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 own next_id watermark.
  3. The serde representation of Id is its inner NonZeroU64, so an Id can appear in user Document types verbatim and round- trip through postcard.

§Power-of-ten posture

  • Rule 5. NonZeroU64 is the type-level invariant; the try_new constructor is the runtime boundary.
  • Rule 7. Wraparound at u64::MAX returns Error::IdSpaceExhausted — never a panic.

Structs§

Id
Per-collection document identifier.

Functions§

bump_next_id
Allocator shim used by the catalog to mint the next Id in a collection.