Comments (4)
deno_bindgen
is for runtime FFI. For embedding usecases, you should use deno_ops
: https://github.com/denoland/deno_core/tree/main/ops
An example can be found here: https://github.com/denoland/deno_core/blob/main/core/examples/hello_world.rs
The repository for issues related to deno_ops is denoland/deno_core
from deno_bindgen.
@littledivy I had already looked at deno_ops
(and for that matter the version exported from deno_core
as op2
). That makes it very easy to export individual functions from Rust to Deno. However, that then requires writing a JS or TS module that wraps those ops, to provide types and methods. What I was hoping for was the ability to export an ES6 module from Rust, similarly to what deno_bindgen provides or what rquickjs
provides, without having to write those two wrappers (a Rust wrapper for each method exposing it as a function, and a JS/TS wrapper for each function turning it back into a method).
Ideally, I'd love to write something like this,:
#[deno_core::something(my_es6_module)]
mod my_module {
#[deno_core::something_else]
struct SomeType {
field: Type,
}
#[deno_core::something]
impl SomeType {
fn new() -> Self { todo!() }
fn method(&self, arg: Abc) { todo!() }
fn another_method(&mut self, arg: Xyz) { todo!() }
}
// optionally some module initialization code, other types, constants, functions, etc
}
my_es6_module::init_ops_and_esm()
Right now, if I already have that type, I have to write three ops, export those in an extension, and write a JS/TS file defining a type with methods wrapping those three ops.
Is this something that just doesn't exist today? Is anything like this on the roadmap?
from deno_bindgen.
Hey @joshtriplett. Something like this currently doesn't exist. Not sure about the roadmap at the moment, but I know that both @littledivy and @mmastrac have been discussion something like that as a potential new feature. So unfortunately for now you'll have to resort to writing the JS/TS glue code.
from deno_bindgen.
I've got some ideas on how we can extend our op system to do that. We're not too far off, and we recently landed the first bits of support for cpp_gc which was the last missing piece to integrate with GC.
from deno_bindgen.
Related Issues (20)
- Encode as cstring instead of ptr + len HOT 2
- Argument of type 'bigint' is not assignable to parameter of type 'PointerObject'.deno-ts(2345) HOT 2
- Problem with struct params HOT 3
- cargo not building on linux
- issue with compilation and intellisence
- Pointers
- intellisence
- Stateless macro HOT 1
- Support for Result type
- 0.9 release checklist HOT 1
- Result<T>,Option<T> & Exceptions
- Embedding deno in rust application HOT 2
- Support for booleans
- Support for unsafe functions
- Support TypedArray types...
- Support for pointers
- Found a bug
- Release 9.0? HOT 1
- Bug: missing crate version/bad documentation HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deno_bindgen.