Class: Oso::Polar::FFI::RustString
- Inherits:
-
FFI::AutoPointer
- Object
- FFI::AutoPointer
- Oso::Polar::FFI::RustString
- 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
52 53 54 |
# File 'lib/oso/polar/ffi.rb', line 52 def self.release(ptr) Rust.free(ptr) unless ptr.null? end |
Instance Method Details
#to_s ⇒ 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
48 49 50 |
# File 'lib/oso/polar/ffi.rb', line 48 def zero? null? end |