mirror of
https://github.com/mailscope/kumomta.git
synced 2026-08-20 19:38:18 +00:00
42bf5c5e61
We've been hoping that mkdocs-material will ship the much anticipated search enhancements for some time, but it's time to recognize that we need to do something to improve the search results with how things work right now. This is a big commit that changes the titles of the various pages from the code-annotated synopsis to just the name of the function. This makes it much easier now to match things like `kumo.reject` directly, but `reject` remains awkward to find. I think this is the best that we can do at this time. A few functions have been annotated with the `status: deprecated` to show as deprecated in the toc/nav (shows with a little trash can next to the name).
2.0 KiB
2.0 KiB
Module kumo.uuid
This module provides functions for parsing and generating UUIDs.
The UUID Object
The functions in this module return a Uuid object.
Printing or otherwise explicitly converting a Uuid object
as a string will produce the the hyphenated form of the uuid.
The following fields are available to return the bytes encoded in various ways.
bytes- returns the data as a binary byte string. This is the most compact representation, but is difficult to pass into other systems without encoding in some way. Case sensitive. See also kumo.encode.hyphenated- returns the data encoded as lowercase hexadecimal with the elements of the UUID separated by hyphens. Case insensitive. Example:69994630-3e27-11ef-91fc-cc28aa0a5c5asimple- returns the data encoded as lowercase hexadecimal with no separating hyphens. Case insensitive. Example:699946303e2711ef91fccc28aa0a5c5a.braced- returns the data encoded as lowercase hexadecimal with the elements of the UUID separated by hyphens, all enclosed in curly braces. Case insensitive. Example:{69994630-3e27-11ef-91fc-cc28aa0a5c5a}urn- returns the data formatted as an URN. Example:urn:uuid:69994630-3e27-11ef-91fc-cc28aa0a5c5a.
local u = kumo.uuid.parse '69994630-3e27-11ef-91fc-cc28aa0a5c5a'
assert(tostring(u) == '69994630-3e27-11ef-91fc-cc28aa0a5c5a')
assert(u.hyphenated == '69994630-3e27-11ef-91fc-cc28aa0a5c5a')
assert(u.simple == '699946303e2711ef91fccc28aa0a5c5a')
assert(u.braced == '{69994630-3e27-11ef-91fc-cc28aa0a5c5a}')
assert(u.urn == 'urn:uuid:69994630-3e27-11ef-91fc-cc28aa0a5c5a')
assert(
u.bytes
== '\x69\x99\x46\x30\x3e\x27\x11\xef\x91\xfc\xcc\x28\xaa\x0a\x5c\x5a'
)
-- You may also combine the bytes representation with the encodings
-- provided in the kumo.encode module for an even more compact non-binary
-- representation of the uuid
assert(
kumo.encode.base64url_nopad_encode(u.bytes) == 'aZlGMD4nEe-R_MwoqgpcWg'
)