{"id":31769192,"url":"https://github.com/second-state/wasmedge-bindgen","last_synced_at":"2025-10-10T02:41:42.714Z","repository":{"id":43051004,"uuid":"439324917","full_name":"second-state/wasmedge-bindgen","owner":"second-state","description":"Let WebAssembly's exported function support more data types for its parameters and return values.","archived":false,"fork":false,"pushed_at":"2023-10-17T10:45:03.000Z","size":93,"stargazers_count":30,"open_issues_count":10,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-09-19T00:25:58.991Z","etag":null,"topics":["wasmedge","webassembly"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/second-state.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-17T12:28:07.000Z","updated_at":"2024-10-01T14:54:17.000Z","dependencies_parsed_at":"2024-06-19T01:40:15.956Z","dependency_job_id":"7fb3732c-182f-4ab7-b771-431d340b6ac5","html_url":"https://github.com/second-state/wasmedge-bindgen","commit_stats":{"total_commits":37,"total_committers":3,"mean_commits":"12.333333333333334","dds":"0.43243243243243246","last_synced_commit":"b3856dafa132171d66d941142f6501b8f7b48bad"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/second-state/wasmedge-bindgen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fwasmedge-bindgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fwasmedge-bindgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fwasmedge-bindgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fwasmedge-bindgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/second-state","download_url":"https://codeload.github.com/second-state/wasmedge-bindgen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fwasmedge-bindgen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002541,"owners_count":26083403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["wasmedge","webassembly"],"created_at":"2025-10-10T02:41:37.036Z","updated_at":"2025-10-10T02:41:42.703Z","avatar_url":"https://github.com/second-state.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"## About\n\nLet WebAssembly's exported function support more data types for its parameters and return values.\n\n## Example\n\n\n## Export Rust things to host program\n\nSee demo program in [rust_bindgen_func](/test/BindgenFuncs/wasm/rust_bindgen_funcs/).\n\n```rust\nuse wasmedge_bindgen::*;\nuse wasmedge_bindgen_macro::*;\n\n// Export a `say` function from Rust, that returns a hello message.\n#[wasmedge_bindgen]\npub fn say(s: String) -\u003e String {\n\tlet r = String::from(\"hello \");\n\treturn r + s.as_str();\n}\n```\n\nRun with command will compile the above code to a WASM bytes file.\n\n```bash\ncargo build --target wasm32-wasi --release\n```\n\n### Rust SDK \nUse exported functions in [Rust SDK](https://github.com/WasmEdge/WasmEdge/tree/master/bindings/rust/wasmedge-sdk).\n\nRefer to the completed exmaple in [rust-sdk-test](/test/BindgenFuncs/host/rust-sdk-test/src/main.rs)\n\n```rust\n\nfn main() {\n\t....\n\n    let vm = Vm::new(Some(config)).unwrap();\n    let args: Vec\u003cString\u003e = env::args().collect();\n    let wasm_path = Path::new(\u0026args[1]);\n    let module = Module::from_file(None, wasm_path).unwrap();\n    let vm = vm.register_module(None, module).unwrap();\n    let mut bg = Bindgen::new(vm);\n\n    // create_line: string, string, string -\u003e string (inputs are JSON stringified)\n    let params = vec![\n        Param::String(\"{\\\"x\\\":2.5,\\\"y\\\":7.8}\"),\n        Param::String(\"{\\\"x\\\":2.5,\\\"y\\\":5.8}\"),\n        Param::String(\"A thin red line\"),\n    ];\n    match bg.run_wasm(\"create_line\", params) {\n        Ok(rv) =\u003e {\n            println!(\n                \"Run bindgen -- create_line: {:?}\",\n                rv.unwrap().pop().unwrap().downcast::\u003cString\u003e().unwrap()\n            );\n        }\n        Err(e) =\u003e {\n            println!(\"Run bindgen -- create_line FAILED {:?}\", e);\n        }\n    }\n\n\t...\n}\n\n```\n\n### Go SDK \nUse exported Rust things from [WasmEdge-go](https://github.com/second-state/WasmEdge-go)!\n\nRefer to the completed example in [bindgen_funcs.go](./test/BindgenFuncs/host/go/bindgen_funcs.go)\n\n```go\nimport (\n\t\"github.com/second-state/WasmEdge-go/wasmedge\"\n\tbindgen \"github.com/second-state/wasmedge-bindgen/host/go\"\n)\n\nfunc main() {\n\t.\n\t.\n\t.\n\n\t// Instantiate the bindgen and vm\n\tbg := bindgen.Instantiate(vm)\n\n\t\t/// say: string -\u003e string\n\tres, _ := bg.Execute(\"say\", \"wasmedge-bindgen\")\n\tfmt.Println(\"Run bindgen -- say:\", res[0].(string))\n}\n```\n\n## Guide\n\n[**Find all the data types you can use!**](bindgen/rust/macro)\n\nYou can find how to call the exported function from go host [here](host/go).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecond-state%2Fwasmedge-bindgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsecond-state%2Fwasmedge-bindgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecond-state%2Fwasmedge-bindgen/lists"}