rfc.uuid
- UUID ¶This module implements UUID defined in RFC9562.
It provides generators of UUID version 1, 4, 6 and 7, and writer/parser of the string represenation of UUIDs.
{rfc.uuid
}
Class of UUID instances. UUID instances are immutable.
{rfc.uuid
}
Returns the raw value of uuid as 16-element u8vector
.
You shouldn’t mutate the returned u8vector.
{rfc.uuid
}
Returns the version number of uuid.
{rfc.uuid
}
A comparator to compare and hash uuids. See Basic comparators.
Note: Equality of uuids can be tested with equal?
.
{rfc.uuid
}
Takes a string representation of UUID, parses it and returns
an uuid instance. If the string isn’t a valid UUID representation,
an error is thrown if the if-invalid keyword argument is omitted
or :error
, and #f
is returned if if-invalid is #f
.
Other than XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
format,
it recognizes the one with urn:uuid:
prefix,
the one enclosed by curly braces, and the one without hyphens.
{rfc.uuid
}
Writes out a string representation of uuid,
in XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
format, to the given
port. If the port is omitted, current output port is used.
{rfc.uuid
}
Returns a string representation of uuid,
in XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
format.
{rfc.uuid
}
We use PRNG to generate UUIDs. By default, we internally creates
a random source and randomize it. You can alter the random source
using parameterize
. The value must be a SRFI-27 random source
(see srfi.27
- Sources of Random Bits).
The value of this parameter is taken when a uuid generator
is created by one of make-uuid*-generator
. Once a
generator is created, the random source is kept in the generator
and won’t be affected by changing the value of this parameter.
{rfc.uuid
}
Returns new generators of uuid v1 and uuis v6
(timestamp and node id based), respectively.
The difference between version 1 and version 6 is the order of timestamp field; version 1 stores lower bits of timestamp first, while version 6 stores higher bits first. That makes v6 uuids created around the same time cluster together when sorted, making it favorable choice over v1 for database index. (However, if you need chronologically orderable uuids, you should use v7 uuids.)
The optional node-id argument must be 48bit exact integer specifing the node ID (IEEE802 MAC address of the machine). If it is omitted, we generate a process-global random node ID (with the multicast bit set to 1, so that it won’t conflict with existing MAC address).
The generators created by these procedures are thread-safe.
{rfc.uuid
}
Returns a new generator that yields uuids with
version 4 algorithm (random numbers).
The generators created by this procedures are thread-safe.
{rfc.uuid
}
Returns a new generator that yields uuids with version 7 algorithm
(time-ordered).
The uuid consists of timestamp part, and monotonically increasing
random bits. Overall, it is ordered chronologically.
The random bit part is splitted to 12bit rand_a
field
and 62bit rand_b
field in UUID RFC. The RFC doesn’t
precisely specify how to fill them. In our implementation,
we treat it as 74bit unsigned integer, and use the following
strategy:
The optional increment-bits argument must be an positive exact integer. The default value is 64. You may want to pass a smaller number if you need to create a lots of UUIDs in very short span of time.
The generators created by this procedures are thread-safe.
{rfc.uuid
}
Deprecated.
Use uuid-random-source
parameter
to customize random source to be used in uuid generation.
{rfc.uuid
}
Pre-created uuid generators for convenience.
Those generators are created with the corresponding
make-uuid*-generator
when the library is loaded,
so they use the default random source.
These generators are thread-safe.
{rfc.uuid
}
Returns a nil-UUID (all bits zero).