Accessing structs via FFI
Hi,
I am trying to do some FFI. On the Rust side I have this struct
This is represented Deno side like so
The login function works, but I am not sure how to safely access the struct data.
2 Replies
You can't use a generic in a struct you want to share in ffi different types will give different memory layout
If your login API is something like:
then that definition seems fully correct. The returned struct is stored in a libffi-allocated buffer of memory that is given to you in the returned Uint8Array: that memory is fully JS owned at that point and entirely safe to access.