Call Rust function from Deno API
I am new in deno.
My question is what is the best way to call rust code in a deno api like oak?
I tried it with https://napi.rs/ which did not work.
Is there something similar for deno?
5 Replies
There are two ways to call native code from within JavaScript running in Deno:
1. Compile native code to WASM and call that
2. Use FFI, see https://docs.deno.com/runtime/manual/runtime/ffi_api
Foreign Function Interface | Deno Docs
As of Deno 1.13 and later, the FFI (foreign function interface) API allows users
thanks I will try it out
I tried it out one question is threre a way send strings and return strings with deno ffi?
Yes, strings are essentially buffers
Yes, by encoding strings to a
Uint8Array
and decoding that with TextDecoder
on the JS side