The UUID structure

The UUID structure provides an implementation of UUIDs (Universally Unique IDentifiers). UUIDs, which are also known as GUIDs (Globally Unique IDentifiers), are sequences of 16-bytes.

Synopsis

structure UUID

Interface

type t

val null : t

val compare : t * t -> order

val same : t * t -> bool

val hash : t -> word

val toString : t -> string

val fromString : string -> t option

val toBytes : t -> Word8Vector.vector

val fromBytes : Word8Vector.vector -> t

Description

type t

the abstract type of UUIDs.

val null : t

null is the all-zeros UUID

val compare : t * t -> order

compare (uuid1, uuid2) does a byte-wise comparison of the two UUIDs and returns their order.

val same : t * t -> bool

same (uuid1, uuid2) does a byte-wise comparison of the two UUIDs and returns true is they are equal and false otherwise.

val hash : t -> word

hash uuid returns a hash of the UUID.

val toString : t -> string

toString uuid formats uuid as a string of the form

"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
where each "`x`" is a lower-case hexadecimal digit.  The first two digits
in the string correspond to the first byte, and so on.
val fromString : string -> t option

fromString s converts the string s, which should be of the form returned by toString to SOME uuid, where uuid is the UUID denoted by the string. Leading whitespace is ignored. If the string does not have the correct format, then NONE is returned.

val toBytes : t -> Word8Vector.vector

toBytes uuid returns the 16-element Word8Vector.vector value that represents uuid.

val fromBytes : Word8Vector.vector -> t

fromBytes bytes takes a 16-element vector of bytes and converts it to a UUID. The Size exception is raised if the length of the vector is not exactly 16. Otherwise, there is no validity chechking of the UUID (i.e., the variant and type are not checked).