Method: Mongo::Crypt::Binary.wrap_string

Defined in:
lib/mongo/crypt/binary.rb

.wrap_string(str) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Wraps a String with a mongocrypt_binary_t, yielding an FFI::Pointer to the wrapped struct.



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/mongo/crypt/binary.rb', line 145

def self.wrap_string(str)
  binary_p = Binding.mongocrypt_binary_new_from_data(
    FFI::MemoryPointer.from_string(str),
    str.bytesize,
  )
  begin
    yield binary_p
  ensure
    Binding.mongocrypt_binary_destroy(binary_p)
  end
end