Class: Oso::Polar::FFI::RustString

Inherits:
FFI::AutoPointer
  • Object
show all
Defined in:
lib/oso/polar/ffi.rb,
lib/oso/polar/ffi/rust_string.rb

Overview

Wrapper class for Rust strings.

Since we force all strings to go through this the `AutoPointer` class will handle actually freeing the string when deleting it

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.release(ptr) ⇒ Object



47
48
49
# File 'lib/oso/polar/ffi.rb', line 47

def self.release(ptr)
  Rust.free(ptr) unless ptr.null?
end

Instance Method Details

#to_sString

Returns:

  • (String)


15
16
17
# File 'lib/oso/polar/ffi/rust_string.rb', line 15

def to_s
  @to_s ||= read_string.force_encoding('UTF-8')
end

#zero?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/oso/polar/ffi.rb', line 43

def zero?
  null?
end