struct UID9
- UID9
- Struct
- Value
- Object
Included Modules
- Comparable(UID9)
Defined in:
uid.crConstructors
-
.empty : self
Generates an empty UUID.
- .new(bytes : StaticArray(UInt8, 9))
-
.new(slice : Slice(UInt8))
Creates UUID from 16-bytes slice.
-
.new(value : String)
Creates new UUID by decoding
value
string from hyphenated (ieba714f86-cac6-42c7-8956-bcf5105e1b81
), hexstring (ie89370a4ab66440c8add39e06f2bb6af6
) or URN (ieurn:uuid:3f9eaf9e-cdb0-45cc-8ecb-0e5b2bfb0c20
) format, raising anArgumentError
if the string does not match any of these formats. -
.new(uuid : UUID)
Creates another
UUID
which is a copy of uuid -
.random(random : Random = Random::Secure) : self
Generates RFC 4122 v4 UUID.
Instance Method Summary
- #<=>(other : UUID) : Int32
-
#bytes : StaticArray(UInt8, 16)
Returns the binary representation of the UUID.
- #hexstring : String
-
#inspect(io : IO) : Nil
Convert to
String
in literal format. -
#to_s(io : IO) : Nil
Same as
#inspect(io)
. -
#to_unsafe
Returns unsafe pointer to 16-bytes.
Constructor Detail
Generates an empty UUID.
UID.empty # => UID9(00000000-0000-4000-0000-000000000000)
Creates UUID from 16-bytes slice. Raises if slice isn't 16 bytes long
Creates new UUID by decoding value
string from hyphenated (ie ba714f86-cac6-42c7-8956-bcf5105e1b81
),
hexstring (ie 89370a4ab66440c8add39e06f2bb6af6
) or URN (ie urn:uuid:3f9eaf9e-cdb0-45cc-8ecb-0e5b2bfb0c20
)
format, raising an ArgumentError
if the string does not match any of these formats.
Generates RFC 4122 v4 UUID.
It is strongly recommended to use a cryptographically random source for
random, such as Random::Secure
.