Giter Club home page Giter Club logo

wasm-components-example's Introduction

Wasm components example

This repository contains an example of a WebAssembly interface, implemented in Rust as a WebAssembly component, then consumed from other Rust and C++ components.

It is a showcase of the wit-bindgen tooling from the Bytecode Alliance.

Building, linking, and executing

# building the implementation
$ cd rust-wasi-impl && make build

# building, linking, and running the C++ example
$ cd cpp-consumer && make bindgen build link run

# building, linking, and running the Rust example
$ cd rust-consumer && make build link run

Prerequisites

wasm-components-example's People

Contributors

radu-matei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wasm-components-example's Issues

Question: Dynamic Loading of WASM components.

Hi,

Thanks for this excellent example. It works well.

I am not sure this is the right "forum" to ask, but please point me to alternatives. However, I have a question: The example loads the modules statically. I have a use case in mind where I dynamically load WASM modules - depending on a configuration - and there can be different type of module combinations, so it does not make much sense to combine all possible modules together into one big fat binary (e.g. security issues, updating individual modules, hot reloading of new module versions etc.). Nevertheless, the modules have standard interfaces, so one can assume that at runtime the interfaces do not change, but just the underlying implementation. Maybe to facilitate the understanding, one can compare it to a plugin system.

I just wonder how one would realize this using WASM components. For example, the Wasmtime documentation provides an example that loads dynamically a module. I would like to do the same, but with wasm-components to avoid all the laborious work of copying data into a shared memory, interpreting it, validating the correctness etc.

Thank you.

Best regards

Issue linking cache interface in `rust-consumer`

When following this awesome write-up I ran into issues linking the Wasm library to the rust-consumer module with wasmlink.

To get wasmlink I cloned the wit-bindgen repo and followed the wasmlink README to build it. Specifically, I ran, cargo build -p wasmlink-cli, which resulted in output built to wit-bindgen/target/debug/wasmlink. I modified the first line of the rust-consumer Makefile to target this binary for wasmlink.

Then, I built (with make build) and tried to link the WASI library and run the rust-consumer with make link run. make link fails with:

[2021-12-27T17:44:56Z ERROR] failed to parse interface file `../cache.wit`
    
    Caused by:
        invalid character in identifier '_'
             --> ../cache.wit:4:5
              |
            4 |     runtime_error,
              |     ^
make: *** [Makefile:9: link] Error 1

The interface file was successfully used to build the Wasm library (rust_wasi_impl.wasm); however, wasmlink seems unable to use it. Is there a different way I should be building and running wasmlink?

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.