Module Uuidm
Universally unique identifiers (UUIDs).
Uuidm implements 128 bits universally unique identifiers version 3, 5 (name based with MD5, SHA-1 hashing) and 4 (random based) according to RFC 4122.
References
- P. Leach et al. A universally unique identifier (UUID) URN Namespace, 2005.
v0.9.6 - homepage
UUIDs
type version=[|`V3 of t * stringName based with MD5 hashing
|`V4Random based
|`V5 of t * stringName based with SHA-1 hasing
]The type for UUID versions and generation parameters.
`V3and`V5specify a namespace and a name for the generation.`V4is random based with a private state seeded withRandom.State.make_self_init, usev4_gento specify your own seed.
val v4_gen : Stdlib.Random.State.t -> unit -> tv4 seedis a function that generates random version 4 UUIDs with the givenseed.
Constants
val nil : tnilis the nil UUID.
val ns_dns : tns_dnsis the DNS namespace UUID.
val ns_url : tns_urlis the URL namespace UUID.
val ns_oid : tns_oidis the ISO OID namespace UUID.
val ns_X500 : tns_dnis the X.500 DN namespace UUID.
Comparing
Conversion with UUID binary representation
val of_bytes : ?pos:int -> string -> t optionof_bytes pos sis the UUID represented by the 16 bytes starting atpos(defaults to0) ins. ReturnsNoneif the string is not long enough.
val to_bytes : t -> stringto_bytes uisuas a 16 bytes long string.
Conversion with UUID US-ASCII representation
val of_string : ?pos:int -> string -> t optionof_string pos sconverts the substring ofsstarting atpos(defaults to0) of the form"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"where X is a lower or upper case hexadecimal number to an UUID. ReturnsNoneif a parse error occured.
val to_string : ?upper:bool -> t -> stringto_string uisuas a string of the form"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"where X is a lower case hexadecimal number (or upper ifupperistrue).
Pretty-printing
val pp : Stdlib.Format.formatter -> t -> unitpp ppf uformatsuonppfliketo_stringwould do. It is unspecified whether upper or lower case hexadecimal numbers are used.
val pp_string : ?upper:bool -> Stdlib.Format.formatter -> t -> unitpp_string ?upper ppf uformatsuonppfliketo_stringwould do.