Skip to main content

bump_next_id

Function bump_next_id 

Source
pub fn bump_next_id<F>(next_id: &mut u64, collection: F) -> Result<Id>
where F: FnOnce() -> String,
Expand description

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

The full allocator lives in Catalog::next_id (M5 issue #38). This module provides only the arithmetic step — incrementing a u64 watermark and rejecting wraparound — so the catalog can be tested in isolation.

The collection argument is a closure that builds the owned collection name on demand, so the happy path never allocates a String. The closure is only invoked on the wraparound / zero-watermark error path.

§Errors

Returns Error::IdSpaceExhausted when the increment would overflow u64::MAX. At 10⁹ inserts/sec this is ~584 years; the check is defensive (Rule 5) and cheap.