struct UUID

Overview

Represents a UUID (Universally Unique IDentifier).

NOTE To use UUID, you must explicitly import it with require "uuid"

Included Modules

Defined in:

cbor/from_cbor.cr
cbor/to_cbor.cr

Constructors

Instance Method Summary

Instance methods inherited from class Object

to_cbor(io : IO)
to_cbor(encoder : CBOR::Encoder)
to_cbor : Bytes
to_cbor

Class methods inherited from class Object

from_cbor(string_or_io) from_cbor

Constructor Detail

def self.new(pull : CBOR::Decoder) #

Creates UUID from CBOR using CBOR::Decoder.

require "cbor"

class Example
  include CBOR::Serializable

  property id : UUID
end

hash = {"id" => "ba714f86-cac6-42c7-8956-bcf5105e1b81"}
example = Example.from_cbor hash.to_cbor
example.id # => UUID(ba714f86-cac6-42c7-8956-bcf5105e1b81)

[View source]

Instance Method Detail

def to_cbor(cbor : CBOR::Encoder) #

Returns UUID as CBOR value.

uuid = UUID.new("87b3042b-9b9a-41b7-8b15-a93d3f17025e")
uuid.to_cbor

[View source]