Code Monkey home page Code Monkey logo

wasmbin's Introduction

wasmbin

wasmbin is a library implementing low-level parsing and serialization of WebAssembly binaries.

Public API

The entry point is the Module object.

From there you can explore the module contents by simply looking up the nested fields. The structures map pretty much 1:1 to raw WebAssembly binary format, so you can also use the specification as a reference.

Supported feature extensions

Following WebAssembly proposals are supported in addition to the core spec and can be enabled via corresponding Cargo features:

Motivation

Original blog post explaining motivation and internals: wasmbin: a self-generating WebAssembly parser & serializer.

This crate intends to provide a low-level representation of the WebAssembly module that is fully described by Rust type system. It also leverages the said type system in conjunction with custom proc-macros to autogenerate parsing/serialization/visitation code for any complex types (structures and enums).

On the user's side this approach allows any type can be used independently to represent/parse/serialize only part of the module, while on the maintainers' side it makes adding and testing new WebAssembly features as quick and easy as adding new types, fields, and variants, without having to write any manual code at all.

One other notable feature is a Lazy<T> wrapper used in wasmbin whenever the spec permits efficiently skipping over some contents (e.g. function bodies). It allows minimally invasive, efficient, "zero-cost" editing of WebAssembly modules: during decoding anything that can be skipped, is skipped over lazily (the Lazy<...> container simply stores the raw bytes), and during encoding only the modified parts of the module are re-encoded, while any untouched parts are copied verbatim as raw bytes from the source.

wasmbin's People

Contributors

rreverser avatar bkotsopoulossc avatar jake-shadle 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.