You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Passing raw bytes from Swift to Rust or Rust to Swift is currently pretty annoying and safety is not guaranteed.
As a solution, I propose a SwiftData(pub Vec<u8>) struct to be added to the swift_bridge crate. It would translate to the Swift Data class. Rust functions should both be able to take it as an argument and return it.
so we could initialize a rust Vec from swift by calling the following:
// Assume data is a Swift Data instance
letdata_byte_array= data.bytes
data_byte_array.withUnsafeBufferPointer({ initialPtr inletdata_vec=make_rust_vec_with_initial_contents(initialPtr)})
This works in the meantime, but I agree, native Data support would be nice!
Passing raw bytes from Swift to Rust or Rust to Swift is currently pretty annoying and safety is not guaranteed.
As a solution, I propose a
SwiftData(pub Vec<u8>)
struct to be added to theswift_bridge
crate. It would translate to the SwiftData
class. Rust functions should both be able to take it as an argument and return it.As a solution to this problem in the past, I made some helper types here: https://github.com/SideStore/minimuxer/blob/master/generated/minimuxer-helpers.swift
The code from these helper types might be useful for converting Data into Vec<u8>.
The text was updated successfully, but these errors were encountered: