Class: TigerBeetle::Converters::UInt128

Inherits:
Base
  • Object
show all
Defined in:
lib/tigerbeetle/converters/uint_128.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

from_native, to_native

Class Method Details

.native_typeObject



7
8
9
# File 'lib/tigerbeetle/converters/uint_128.rb', line 7

def self.native_type
  TBClient::UInt128
end

Instance Method Details

#from_native(ptr) ⇒ Object



11
12
13
14
# File 'lib/tigerbeetle/converters/uint_128.rb', line 11

def from_native(ptr)
  c_value = TBClient::UInt128.new(ptr)
  c_value[:low] + (c_value[:high] << 64)
end

#to_native(ptr, value) ⇒ Object



16
17
18
19
20
21
# File 'lib/tigerbeetle/converters/uint_128.rb', line 16

def to_native(ptr, value)
  TBClient::UInt128.new(ptr).tap do |result|
    result[:low] = value % 2**64
    result[:high] = value >> 64
  end
end