Coder Social home page Coder Social logo

wasm_plugin's Introduction

A low-ish level tool for easily writing and hosting WASM based plugins.

The goal of wasm_plugin is to make communicating across the host-plugin boundary as simple and idiomatic as possible while being unopinionated about how you actually use the plugin.

Loading a plugin is as simple as reading the .wasm file off disk.

let mut plugin = WasmPluginBuilder::from_file("path/to/plugin.wasm")?.finish()?;

Calling functions exported by the plugin takes one of two forms. Either the function takes no arguments and returns a single serde deserializable value:

let response: ResultType = plugin.call_function("function_name")?;

Or it takes a single serializable argument and returns a single result:

let message = Message::default();
let response: ResultType = plugin.call_function_with_argument("function_name", &message)?;

Exporting a function from a plugin is just a matter of wrapping it in a macro:

fn local_hello() -> String {
    "Hello, host!".to_string()
}
wasm_plugin_guest::export_plugin_function_with_no_input(hello, local_hello);

API Stability

I am not currently guaranteeing any stability, expect all releases to include breaking changes.

wasm_plugin's People

Contributors

alec-deason 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.