Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

rust How to pass out parameter to function from Swift FFI

// Create storage
var content: UnsafeMutablePointer<CChar>? // Could be NULL, so Optional
var length: Int32 = 0
var capacity: Int32 = 0

// Pass as references
do_something(&content, &length, &capacity)

// Copy the data
let data = Array(UnsafeRawBufferPointer(start: content, count: Int(length)))
 
PREVIOUS NEXT
Tagged: #rust #How #pass #parameter #function #Swift #FFI
ADD COMMENT
Topic
Name
9+1 =