Repository navigation
Replies: 1 comment
|
Great use case to think through, and the answer is: yes, this is precisely what Deno's embeddable core is for — but the important thing to understand is that FFI and embedding are two opposite directions, and the right one depends on who calls whom. Direction 1 — Deno calls Rust: FFI. const lib = Deno.dlopen("./libpumpkin_plugin.so", {
send_packet: { parameters: ["pointer", "u32"], result: "i32" },
});Direction 2 — Rust calls JS: embedding #[op2]
#[string]
fn op_send_packet(#[string] player: String, #[serde] payload: serde_json::Value) -> Result<(), AnyError> {
// call into Pumpkin internals here
}
deno_core::extension!(pumpkin_api,
ops = [op_send_packet, /* ... */],
);
// build the runtime:
let mut runtime = JsRuntime::new(RuntimeOptions {
extensions: vec![pumpkin_api::init_ops()],
..Default::default()
});
runtime.execute_script("plugin.js", plugin_code)?;Plugins are then plain Practical notes for a plugin system specifically: one |
Uh oh!
There was an error while loading. Please reload this page.
Hello ! First of all, I'm not asking for help in writing code, but rather to ask what's possible to do with Deno.
I'm interested in a Rust project called PumpkinMC, which is a reimplementation of the minecraft server protocol in Rust, and they have a plugin API (in early stages) and they are opened ideas and interested in exposing their PluginAPI to other languages, but they still didn't decided how to do it and if they'll do it, as far as I saw. I don't want to speak in their name as I'm not a contributor, just really enthusiast in their work.
I thought about Deno because I saw that Deno had a FFI support so I was wondering if Deno could be a good option in order to make a plugin in Javascript. I saw this repo but it seems to be inactive. I don't expect Deno to be an out of the box solution to execute and access Rust code from javascript, but I wonder if it would be a good idea.
All reactions