Ulid.generate

UlidResult generate() static @safe nothrow @nogc

Generates a ULID for the current time, with 80 fresh random bits from the operating system's cryptographically secure random number generator. Two calls in the same millisecond produce unrelated values; use UlidGenerator when they must increase.

Returns

the ULID, or UlidError.CLOCK_FAILURE when the system clock

cannot be read or is set before 1970, UlidError.TIMESTAMP_OVERFLOW after the year 10889, or UlidError.ENTROPY_FAILURE when the operating system cannot supply randomness.

UlidResult generate(ulong timestampMs) static @safe nothrow @nogc

Generates a ULID for a given time, with 80 fresh random bits from the operating system.

Parameters

timestampMsmilliseconds since the Unix epoch, at most MAX_TIMESTAMP.

Returns

the ULID, or UlidError.TIMESTAMP_OVERFLOW or

UlidError.ENTROPY_FAILURE.