UlidGenerator.next

UlidResult next() @safe nothrow @nogc

Generates the next ULID for the current time.

Returns

the ULID, or UlidError.CLOCK_FAILURE,

UlidError.TIMESTAMP_OVERFLOW, UlidError.RANDOM_OVERFLOW or UlidError.ENTROPY_FAILURE.

UlidResult next(ulong timestampMs) @safe nothrow @nogc

Generates the next ULID for a given time. Fresh randomness comes from the operating system, and only when the timestamp moves past the last one.

Parameters

timestampMsmilliseconds since the Unix epoch, at most Ulid.MAX_TIMESTAMP.

Returns

the ULID, or UlidError.TIMESTAMP_OVERFLOW,

UlidError.RANDOM_OVERFLOW or UlidError.ENTROPY_FAILURE.

UlidResult next(ulong timestampMs, const ubyte[Ulid.RANDOM_LENGTH] randomness) @safe pure nothrow @nogc

Generates the next ULID for a given time with caller-supplied randomness, for a custom random source or for reproducible sequences.

Parameters

timestampMsmilliseconds since the Unix epoch, at most Ulid.MAX_TIMESTAMP.
randomnessthe random component to use if the timestamp moves past the last one; ignored otherwise.

Returns

the ULID, or UlidError.TIMESTAMP_OVERFLOW or

UlidError.RANDOM_OVERFLOW.