Skip to main content

generate_id

Function generate_id 

Source
pub fn generate_id() -> String
Expand description

Generate a lex-sortable, monotonic-ish unique ID.

Format: 32 hex chars of as_nanos() (zero-padded) followed by 8 hex chars of a per-process atomic counter. The counter prevents collisions when two inserts hit the same nanosecond and — critically — keeps order stable: an id minted at the same nanosecond is monotonically greater than the previous one. Width is fixed at 40 chars so lexicographic comparison matches creation order, which is what cursor pagination relies on.