class Oso::Polar::FFI::Message

Wrapper class for Message FFI pointer + operations.

Wrapper class for Message FFI pointer + operations.

Constants

Rust

Public Class Methods

release(ptr) click to toggle source
# File lib/oso/polar/ffi.rb, line 45
def self.release(ptr)
  Rust.free(ptr) unless ptr.null?
end

Public Instance Methods

process(enrich_message) click to toggle source
# File lib/oso/polar/ffi/message.rb, line 22
def process(enrich_message)
  message = JSON.parse(to_s)
  kind = message['kind']
  msg = message['msg']
  msg = enrich_message.call(msg)

  case kind
  when 'Print'
    puts(msg)
  when 'Warning'
    warn(format('[warning] %<msg>s', msg: msg))
  end
end
to_s() click to toggle source

@return [String]

# File lib/oso/polar/ffi/message.rb, line 11
def to_s
  @to_s ||= read_string.force_encoding('UTF-8')
end