#Creating custom ops for deno_core that take in arrays and strucks
2 messages · Page 1 of 1 (latest)
I wasn't able to find the answer to your question in the official Deno documentation. However, based on your message, I can provide some general advice.
When creating custom ops for deno_core, you typically need to define the ops in Rust and then expose them to your JavaScript or TypeScript code. Here's a brief overview of what you might need to do:
-
Define your custom op in Rust, making sure it accepts a
Vec<String>as an argument. You'll need to use theop_syncorop_asyncmacros provided bydeno_coreto define your op. -
Handle the serialization and deserialization of arguments and return values between Rust and JavaScript. You can use serde for serializing your custom enum type or struct.
-
Register your op with the Deno runtime by adding it to the op table when you initialize the runtime.
-
In your JavaScript or TypeScript code, you'll need to use
Deno.core.opSyncorDeno.core.opAsyncto invoke your custom op, passing the necessary arguments.
Please note that this advice is not based on the Deno documentation, and you should double-check the accuracy of the advice given. Since working with deno_core involves Rust and potentially complex interactions between Rust and JavaScript, you may want to look at existing examples in the Deno codebase or seek out community examples that demonstrate similar patterns.