Giter Club home page Giter Club logo

how-to-bindgen's Introduction

how-to-bindgen

This repo of how to create wasm bindings for complex data structures in Rust using fp-bindgen

Why is this useful

WASM functions only accept primitive data types as inputs or output params. The data types are basically floats, ints, and vectors. Out of the box, runtimes like Wasmer and Wasmtime only support these datatypes when running WASM bundles. If you want to interact with WASM functions and use more complex data structures like a HashMaps, arrays, etc. , you need what is called "glue" code to have a mechanism to communicate those datatypes in way WASM can understand. The most common library that does that is wasm-bindgen but it is only useful if you are exchanding those values between Javascript and Rust.

This is where fp-bindgen becomes helpful, it is a tool you can use to be able to interact with WASM functions with your desired complex data structures.

This repo provides a simple example of how to write a protocol that defines the functions imported or exported in your wasm bundle and the input/ouput params. It then shows how to use that protocol to generate bindings (the "glue" code) that act as a bridge between your application and the wasm bundle.

how-to-bindgen's People

Contributors

ameanasad avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.