Module: Spotify::ByteString
- Extended by:
- FFI::DataConverter
- Defined in:
- lib/spotify/data_converters/byte_string.rb
Overview
ByteStrings are for strings that store any binary data, not just regular NULL-terminated strings. It is used for the Spotify application key.
Class Method Summary collapse
- .reference_required? ⇒ Boolean
-
.to_native(value, ctx) ⇒ FFI::Pointer
Given either a String or nil, make an actual FFI::Pointer of that value, without an ending NULL-byte.
Class Method Details
.reference_required? ⇒ Boolean
26 27 28 |
# File 'lib/spotify/data_converters/byte_string.rb', line 26 def reference_required? true end |
.to_native(value, ctx) ⇒ FFI::Pointer
Given either a String or nil, make an actual FFI::Pointer of that value, without an ending NULL-byte.
16 17 18 19 20 21 22 23 |
# File 'lib/spotify/data_converters/byte_string.rb', line 16 def to_native(value, ctx) value && begin value = value.to_str pointer = FFI::MemoryPointer.new(:char, value.bytesize) pointer.write_string(value) end end |