Giter Site home page Giter Site logo

Example using WASI about wasmex HOT 2 CLOSED

tessi avatar tessi commented on May 30, 2024
Example using WASI

from wasmex.

Comments (2)

tessi avatar tessi commented on May 30, 2024

Hey @munjalpatel 👋

thanks and great question! I guess we need to improve our docs in that regard.

There are many examples in our wasi_tests. They include "preopens" of host directories (so that WASI executables can access the host file system). Beware, that file access permissions are likely to be removed or changed in our next major version.

You may also find some hints in our changelog which contains my favourite WASI example :)

# after a `wapm install cowsay`
{:ok, bytes } = File.read("wapm_packages/_/[email protected]/target/wasm32-wasi/release/cowsay.wasm")
{:ok, stdout} = Wasmex.Pipe.create()
{:ok, stdin} = Wasmex.Pipe.create()
{:ok, instance } = Wasmex.start_link(%{bytes: bytes, wasi: %{stdout: stdout, stdin: stdin}})
Wasmex.Pipe.write(stdin, "Why do you never see elephants hiding in trees? Because they're really good at it.")
{:ok, _} = Wasmex.call_function(instance, :_start, [])
IO.puts Wasmex.Pipe.read(stdout)
  ________________________________________
/ Why do you never see elephants hiding  \
| in trees? Because they're really good  |
\ at it.                                 /
 ----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
               ||----w |
                ||     ||
:ok

Our official docs may help too. If you find something missing or hard to understand in our docs, I'd be happy for feedback or PRs fixing things :)

Does that help?

from wasmex.

munjalpatel avatar munjalpatel commented on May 30, 2024

Hey @tessi , thanks a lot, this is very helpful. I was able to understand this reading through the code :)

from wasmex.

Related Issues (20)

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.