Uuid

This struct represents a UUID. It offers static members for creating and parsing UUIDs.

This struct treats a UUID as an opaque type. The specification has fields for time, version, client MAC address, and several other data points, but these are meaningless for most applications and means of generating a UUID.

There are versions of UUID generation involving the system time and MAC address. These are not used for several reasons: - One version contains identifying information, which is undesirable. - Ensuring uniqueness between processes requires inter-process communication. This would be unreasonably slow and complex. - Obtaining the MAC address is a system-dependent operation and beyond the scope of this module. - Using Java and .NET as a guide, they only implement randomized creation of UUIDs, not the MAC address/time based generation.

When generating a random UUID, use a carefully seeded random number generator. A poorly chosen seed may produce undesirably consistent results.

Members

Functions

format
ubyte format()

Gets the version of this UUID. RFC 4122 defines five types of UUIDs: - Version 1 is based on the system's MAC address and the current time. - Version 2 uses the current user's userid and user domain in addition to the time and MAC address. - Version 3 is namespace-based, as generated by the NamespaceGenV3 module. It uses MD5 as a hash algorithm. RFC 4122 states that version 5 is preferred over version 3. - Version 4 is generated randomly. - Version 5 is like version 3, but uses SHA-1 rather than MD5. Use the NamespaceGenV5 module to create UUIDs like this.

opEquals
equals_t opEquals(Uuid other)

Determines if this UUID has the same value as another.

toBytes
ubyte[] toBytes()

Get a copy of this UUID's value as an array of unsigned bytes.

toHash
hash_t toHash()

Get a hash code representing this UUID.

toString
char[] toString()

Get the canonical string representation of a UUID. The canonical representation is in hexidecimal, with hyphens inserted after the eighth, twelfth, sixteenth, and twentieth digits. For example: 67e55044-10b1-426f-9247-bb680e5fe0c8 This is the format used by the parsing functions.

Static functions

byName
Uuid byName(Uuid namespace, char[] name, Digest digest, ubyte uuidVersion)
Undocumented in source. Be warned that the author may not have intended to support it.
empty
Uuid empty()

Return an empty UUID (with all bits set to 0). This doesn't conform * to any particular version of the specification. It's equivalent to * using an uninitialized UUID. This method is provided for clarity.

opCall
Uuid opCall(ubyte[] data)

Copy the givent bytes into a UUID. If you supply more or fewer than * 16 bytes, throws an IllegalArgumentException.

parse
Uuid parse(char[] value)

Attempt to parse the representation of a UUID given in value. If the value is not in the correct format, throw IllegalArgumentException. If the value is in the correct format, return a UUID representing the given value.

random
Uuid random(Random generator)

Generate a UUID based on the given random number generator. * The generator must have a method 'uint natural()' that returns * a random number. The generated UUID conforms to version 4 of the * specification.

tryParse
bool tryParse(char[] value, Uuid uuid)

Attempt to parse the representation of a UUID given in value. If the value is not in the correct format, return false rather than throwing an exception. If the value is in the correct format, set uuid to represent the given value.

Meta