Closed Axiver closed 5 months ago
Yeah, you need to call load function for each method, ffi-rs
will cache foreign function symbol so you don't need to worry performance.
In the future, maybe we can also support load multiply methods in a single call
In ffi-rs@1.0.62
, you can use define
methods to define a function signature
const res = define({
sum: {
library: "libsum",
retType: DataType.I32,
paramsType: [DataType.I32, DataType.I32],
},
atoi: {
library: "libnative",
retType: DataType.I32,
paramsType: [DataType.String],
paramsValue: ["1000"],
}
})
equal(res.sum([1, 2]), 3)
equal(res.atoi(["1000"]), 1000)
I have the following code that I want to migrate over from
ffi-napi
toffi-rs
:Is there any method built-into
ffi-rs
for me to load the functions all with one method call? Instead of having to iterate through and callload()
on them one by one. Thank you.