-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: official rust SDK #2684
Comments
Thanks for contacting with us. IMU, the key point is about "a safe Rust SDK over just providing unsafe bindings". I am going to do some research to figure out what does it really means beside using If there are shareable BKMs and recommanded reading lists, feel free 🤝 . |
I would recommend first to generate the ffi bindings rust bindgen https://github.com/rust-lang/rust-bindgen and then build a SDK on top of it. Here is a safe and ergonomic Rust SDK for Sqlite: https://github.com/rusqlite/rusqlite |
A minimal bindgen project could look like this: @lum1n0us is it ok to place the rust-sdk in the wamr repo? |
@0xE282B0 thanks for your contribution. please place it into language-bindings/rust/. There are two sets of C SDK. Generally, it isn't allowed to use both in one program.
|
@0xE282B0 thanks a lot for the advice. For examples on how to use the C SDK, maybe you can refer to: https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/samples/basic/src/main.c#L94-L150 And you can also enable libc-wasi, refer to: |
Hi all, |
a feature branch is better. @wenyongh please create a dev branch for rust-sdk. thanks |
@0xE282B0 I have created |
First commit for the rust-sdk: - Initial bindgen - first example using unsafe code based on discussion in #2684 Signed-off-by: Sven Pfennig <[email protected]>
@Mossaka aftering having a minimal Rust binding, I am thinking about next moves on "build a Rust SDK on top of it.". I went through the rusqlite. It seems to create another set of high-level abstract programming concepts in Rust. I am not sure the same story is able to be reproduced on WAMR side and if it is necessary. So, I guess what's left for us is about "a safe Rust SDK". I found some interesting material about creating a safe interface. Does it explain the concept of "a safe Rust SDK", you mentioned before? |
I think the main thing is to create a Rust SDK that follows Rust idioms and best practices. The article you pasted is a good first step, but at the same time, I think it's important to create a SDK that provides a good developer experience. To name a few points:
You can also see examples of how wasmtime rust SDK works: |
Going to use this comment to track all doing and todo related. DoneNext problems are
ToDo
Done |
Hey there, thanks for putting out a rust-sdk for wamr and I am very excited for it. I went ahead and implement a wamr shim in runwasi: containerd/runwasi#508. However, when I ran the shim, I've got an error |
@Mossaka Sure. I'll help. Btw, I've created an issue (bytecodealliance/wamr-rust-sdk#6) to trace all your comments. please take a look in case I've left something. |
One thing that I didn't like about https://github.com/bytecodealliance/wamr-rust-sdk is that it uses the platform code already in WAMR. (Which is highlighted by how ESP support was added bytecodealliance/wamr-rust-sdk@ceeffbe) For me a better way of integrating with Rust would be: Option 1 (std) would be the default, with a cbindgen platform implementation that uses the standard library and the language alloc feature. Option 2 (no_std) could have the cbindgen API (that uses a "Platform" trait) implemented and the math functions from libm. It would be the developer's responsibility to then implement the "Platform" trait with the needed functionalities. We could even go beyond and have a "PlatformVMCore" and a "PlatformExtension" trait, with the extension trait being optional, but for no_std targets I think just the VMCore functionality is enough. |
Hey 👋,
I am a core maintainer of the CNCF containerd/runwasi project, which facilitates running wasm workloads managed by containerd and Kubernetes. It can be used as a rust library to implement containerd shims who are responsible for managing Wasm containers. We've been asked to add the WebAssembly Micro Runtime support in runwasi as a shim to ensure a wide coverage of runtimes. See issues containerd/runwasi#337 and #2127.
Problem Statement
While we're eager to add support for WebAssembly Micro Runtime in runwasi, the lack of an official, up-to-date Rust crate for
wamr
is hindering progress. I am writing to propose a feature request to publish an official rust SDK for wasm micro runtimePrior Work
There is a community-created rust crate wamr-sys by @rahul-thakoor on crates.io for #230 . However, this crate is not up to date and lacks active maintenance. A fork by @0xE282B0 adds WASI support, which can be found here: https://github.com/0xE282B0/wamr-sys.
Preferred Approach
We prefer a safe Rust SDK over just providing unsafe bindings. This would significantly streamline the integration process and ensure better safety guarantees.
Thank you for considering this feature request. Looking forward to your feedback. 🙏
The text was updated successfully, but these errors were encountered: