Sha256: 1a0b235d4035234a01a7c1ceae5c2115f63e83b8a8134c796c2cc633295d4122

Contents?: true

Size: 488 Bytes

Versions: 1

Compression:

Stored size: 488 Bytes

Contents

# frozen_string_literal: true

require 'ffi'

module Rollenspielsache
  # Wrapped up string
  class FFIString < FFI::AutoPointer
    def self.release
      Binding.free self
    end

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

    # Rust externs
    module Binding
      extend FFI::Library
      ffi_lib 'librollenspielsache'

      # Pass back to Rust's memory management
      attach_function :free, :ffi_string_free, [FFIString], :void
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
librollenspielsache-rb-0.1.1 lib/librollenspielsache/ffi_string.rb