Class: TonSdk::Interop::TcStringData

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/ton_sdk_client/interop.rb

Class Method Summary collapse

Class Method Details

.from_string(s) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/ton_sdk_client/interop.rb', line 20

def self.from_string(s)
  tcs = TcStringData.new
  bytes_count = s.unpack("C*").size
  ptr1 = FFI::MemoryPointer.new(:char, bytes_count)
  ptr1.put_bytes(0, s, 0, bytes_count)
  tcs[:content] = ptr1
  tcs[:len] = ptr1.size
  tcs
end