(rfc uuid) - UUID generate library

Library (rfc uuid)

This library provides RFC 9562 a Universally Unique IDentifier (UUID) URN Namespace procedures.

Class <uuid>

The class representing UUID.

Predicates

Function uuid? obj

Returns #t if the obj is an instance of <uuid>, otherwise #f.

Returns #t if the obj is an instance <uuid> and the named version, otherwise #f.

Compares given 2 uuids and return #t if both have the same values, otherwise #f.

Constructors

Creates a null (empty) uuid.

The returning object will be represented like this UUID;

00000000-0000-0000-0000-000000000000.

Creates a max uuid.

The returning object will be represented like this UUID;

FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF.

Creates version 1, 3, 4, 5, 6 and 7 UUIDs respectively.

For version 1 and 6, the procedures can take an optional argument timestamp which is a 60bit timestamp integer.

For version 3 and 5, the procedures need to take 2 arguments, _namespace_and name. namespace must be a UUID object, and name must be a string.

For version 4, it can take an optional argument prng which specifies pseudo random generator. The default value is (*uuid-random-state*).

For version 7, it can take optional arguments timestamp and prng. The timestamp is 48bit unix time in milliseconds, The default value is current time. The prng is the same as version 4.

Predefined namespaces and parameters

Constant predefined namespace of UUIDs.

Pseudo random generator used by version 4 UUID.

The number of allowed UUIDs in the same time. Used by version 1 UUID.

The default value is 1000.

Parameters for testing purpose. It should not be used in a usual occasion.

Converters

Returns bytevector converted from given uuid.

(uuid->bytevector (make-null-uuid))
#vu8(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)

Returns string represented uuid converted from given uuid.

(uuid->string (make-null-uuid))
00000000-0000-0000-0000-000000000000

Returns uuid object generated from bv.

Given bytevector must have length at least 16.

Returns uuid object generated from string.

Given string must be proper format of UUID defined in RFC 4122.

Returns URN formatted string of given uuid.