Рейтинг@Mail.ru

Module uuid

Module uuid

A “UUID” is a Universally unique identifier. If an application requires that a value be unique only within a single computer or on a single database, then a simple counter is better than a UUID, because getting a UUID is time-consuming (it requires a syscall). For clusters of computers, or widely distributed applications, UUIDs are better.

The functions that can return a UUID are:

The functions that can convert between different types of UUID are:

The function that can determine whether a UUID is an all-zero value is:

uuid.nil

A nil object

uuid.__call()
Return:a UUID
Rtype:cdata
uuid.bin()
Return:a UUID
Rtype:16-byte string
uuid.str()
Return:a UUID
Rtype:36-byte binary string
uuid.fromstr(uuid_str)
Parameters:
  • uuid_str – UUID in 36-byte hexadecimal string
Return:

converted UUID

Rtype:

cdata

uuid.frombin(uuid_bin)
Parameters:
  • uuid_str – UUID in 16-byte binary string
Return:

converted UUID

Rtype:

cdata

object uuid_object
uuid_object:bin([byte-order])

byte-order can be one of next flags:

  • ‘l’ - little-endian,
  • ‘b’ - big-endian,
  • ‘h’ - endianness depends on host (default),
  • ‘n’ - endianness depends on network
Parameters:
  • byte-order (string) – one of 'l', 'b', 'h' or 'n'.
Return:

UUID converted from cdata input value.

Rtype:

16-byte binary string

uuid_object:str()
Return:UUID converted from cdata input value.
Rtype:36-byte hexadecimal string
uuid_object:isnil()

The all-zero UUID value can be expressed as uuid.NULL, or as uuid.fromstr('00000000-0000-0000-0000-000000000000'). The comparison with an all-zero value can also be expressed as uuid_with_type_cdata == uuid.NULL.

Return:true if the value is all zero, otherwise false.
Rtype:bool

Example

tarantool> uuid = require('uuid')
---
...
tarantool> uuid(), uuid.bin(), uuid.str()
---
- 16ffedc8-cbae-4f93-a05e-349f3ab70baa
- !!binary FvG+Vy1MfUC6kIyeM81DYw==
- 67c999d2-5dce-4e58-be16-ac1bcb93160f
...
tarantool> uu = uuid()
---
...
tarantool> #uu:bin(), #uu:str(), type(uu), uu:isnil()
---
- 16
- 36
- cdata
- false
...