100-nanosecond intervals between 1582-10-15, where version 1 and 6 timestamps start, and 1970-01-01.
reference · one package
API reference
Every public value, function, type and method in moonbitstack/moonuuid. Signatures are the package interface; the notes are the doc comments.
Values
Constants the package exports: the nil and max identifiers, the four namespaces, and the offset between the Gregorian and Unix epochs.
The max identifier, all ones.
The namespaces RFC 9562 assigns for names that are domain names, URLs, ISO OIDs and X.500 distinguished names.
The nil identifier, all zeros.
Functions
Free functions that read text or make one version each.
Text in any of the spellings in use: canonical, with or without hyphens, in braces, with the urn:uuid: prefix; any case.
A version 1 or 6 timestamp from nanoseconds since 1970.
Time-based: a 60-bit timestamp from ticks_of, a 14-bit clock sequence and a 48-bit node, laid out with the low time bits first.
Name-based with MD5: the same namespace and name always give the same identifier. The name is hashed as UTF-8.
Random: 122 of the 16 bytes given are kept.
Name-based with SHA-1, preferred over version 3.
Version 1's fields with the timestamp's high bits first, so the identifiers sort in time order.
Milliseconds since 1970 in the top 48 bits, then 74 bits from the 10 random bytes given: a 42-bit counter whose top bit starts clear, so a generator can count up within a millisecond, and 32 random bits.
Custom: 122 bits of the 16 bytes given, laid out as the caller likes; only version and variant are written over.
Types
The identifier and the generator, with the methods that read or write them.
Identifiers from a clock and a source of random bytes the caller supplies, keeping what the time-based versions need between calls: version 1 and 6 timestamps never repeat or go back, and version 7 ids made within one millisecond count up, so they sort in the order made.
clock gives nanoseconds since 1970; random is where the random bits come from: @system.source from moonrand/system in a program, or a Replay of fixed bytes in a test that wants the same ids every run.
Version 1 with node; the clock sequence is random unless given.
Version 4 from 16 random bytes.
Version 6 with node; the clock sequence is random unless given.
Version 7. Within one millisecond the counter goes up by one with a fresh random tail; when the clock steps back, the millisecond after the last one is used; when the counter runs out, the millisecond moves on.
A 128-bit identifier as RFC 9562 lays it out. Compared, hashed and ordered by its bytes, so a sorted list of time-ordered ids is in time order.
The 16 bytes, most significant first.
The 14-bit clock sequence of versions 1 and 6.
From Compare.
From Eq.
Any spelling parse reads.
From Hash.
From Hash.
The 32 hexadecimal digits, lowercase, without hyphens.
The 48-bit node of versions 1 and 6.
From Eq.
The identifier from its 16 bytes, most significant first.
The identifier from its high and low 64 bits.
From Compare.
From Compare.
From Compare.
From Compare.
The canonical text: 8-4-4-4-12 lowercase hexadecimal digits.
The high and low 64 bits.
The timestamp the fields hold: 100-nanosecond intervals since 1582-10-15 for versions 1 and 6, milliseconds since 1970 for version 7, the version 1 reading of the fields otherwise.
The canonical text.
From Debug.
The canonical text: 8-4-4-4-12 lowercase hexadecimal digits.
urn:uuid: and the canonical text, as RFC 9562 names an identifier.
The variant its bits name.
The version, 1 to 8 for the ones RFC 9562 defines; None when the variant is not RFC 9562's, where the version bits mean nothing.
implementsFromJsonShowToJson
Who an identifier's variant bits say it belongs to.
- Ncs Reserved for NCS backward compatibility.
- Rfc RFC 9562, the variant every version here writes.
- Microsoft Reserved for Microsoft backward compatibility.
- Future Reserved for future definition.
From Eq.
From Eq.
From Show.
From Debug.
From Show.
implementsShow
Errors
The refusal that a parse or a byte-count check raises.
Why text or bytes are not a UUID.
- Malformed(at~ : Int32, reason~ : String) Text that is not 32 hexadecimal digits once braces, hyphens and the urn:uuid: prefix are set aside; at is the offending character.
- Size(want~ : Int32, got~ : Int32) Bytes of the wrong length.
- Random(@moonrand.Unavailable) The generator's random source could not give what an identifier needs.
From Eq.
From Eq.
From Show.
From Debug.
From Show.
implementsShow