-
Notifications
You must be signed in to change notification settings - Fork 175
Open
Labels
area/communityhelp wantedExtra attention is neededExtra attention is neededwasmWebAssembly technologyWebAssembly technology
Description
1. Background
The wit-bindgen project officially provided by WebAssembly can enable better interaction between the wasm module and the runtime, avoiding the development of various data conversion logics, and now Layotto integrates wasmtime, so we want to integrate wit-bindgen to improve the user's ability to develop wasm modules experience.
2. What I have tried
- define a wit file:
record person {
name: string,
age: u32,
}
test: func(who: person) -> string
- develop user module
use hello::*;
wit_bindgen_rust::import!("wit/hello.wit");
fn main() {
let p = Person{name:"gj", age: 18};
let result = test(p);
print!("result: {}", result);
}
- add implementation in wasmtime
use hello::*;
wit_bindgen_rust::export!("/Users/gujin/workspace/rust/hello-wasmtime/wit/hello.wit");
struct Hello {}
impl hello::Hello for Hello {
fn test(p: Person) -> String {
return p.name;
}
}
//register to wasmtime
In this way, the test function can be implemented, but how to register this implementation with wasmtime and provide services to users has not yet been found.
3. what need to do
- Learn how to integrate wit-bindgen with wasmtime
- Learn how to integrate wit-bindgen with wasmtime-go
References:
- https://github.com/bytecodealliance/wit-bindgen
- https://github.com/fermyon/spin
- discussion:Update the api for wasm functions; 设计 FaaS 编程 API #611
中文
一、背景
WebAssembly 官方提供的 wit-bindgen 项目可以让 wasm 模块跟运行时之间更好的交互,避免开发各种数据转换逻辑,现在Layotto集成了wasmtime,因此想要集成wit-bindgen来提高用户开发wasm模块的体验。
二、做过的一些尝试
- 自定义一个wit文件:
record person {
name: string,
age: u32,
}
test: func(who: person) -> string
- 用户开发时使用
use hello::*;
wit_bindgen_rust::import!("wit/hello.wit");
fn main() {
let p = Person{name:"gj", age: 18};
let result = test(p);
print!("result: {}", result);
}
- 运行时提供具体实现
use hello::*;
wit_bindgen_rust::export!("/Users/gujin/workspace/rust/hello-wasmtime/wit/hello.wit");
struct Hello {}
impl hello::Hello for Hello {
fn test(p: Person) -> String {
return p.name;
}
}
//把实现注册到wasmtime
这样可以实现test接口,但是如何把该实现注册到wasmtime,对用户提供服务还没有找到办法。
三、需要做什么
- 调研用wasmtime集成wit-bindgen的方法
- 调研用wasmtime-go集成wit-bindgen的方法
参考资料:
Metadata
Metadata
Assignees
Labels
area/communityhelp wantedExtra attention is neededExtra attention is neededwasmWebAssembly technologyWebAssembly technology