99 releases (36 stable)

new 1.2.2-dev.15 May 6, 2025
1.2.2-dev.13 Apr 30, 2025
1.2.0 Mar 28, 2025
1.1.8 Dec 28, 2024
0.0.16 Mar 30, 2024

#273 in Parser implementations

Download history 356/week @ 2025-01-14 660/week @ 2025-01-21 112/week @ 2025-01-28 84/week @ 2025-02-04 34/week @ 2025-02-11 529/week @ 2025-02-18 222/week @ 2025-02-25 182/week @ 2025-03-04 689/week @ 2025-03-11 412/week @ 2025-03-18 269/week @ 2025-03-25 628/week @ 2025-04-01 566/week @ 2025-04-08 238/week @ 2025-04-15 395/week @ 2025-04-22 473/week @ 2025-04-29

1,716 downloads per month
Used in 12 crates

Apache-2.0

1MB
25K SLoC

Rust 15K SLoC // 0.0% comments WebAssembly 10K SLoC

golem-wasm-rpc

Defines data types for Golem's remote function invocation and conversions between them.

  • WitValue is the WIT-defined generic data type capable of representing an arbitrary value, generated by wit-bindgen
  • A builder and an extractor API for WitValue
  • Value is a recursive Rust type which is more convenient to work with than WitValue. Conversion between WitValue and Value is implemented in both directions.
  • Protobuf message types for describing values and types, and a protobuf version of WitValue itself and conversion from and to Value and WitValue
  • JSON representation of WIT values, as defined in the Golem docs.
  • Conversion of Value to and from wasmtime values

The JSON representation requires additional type information which can be extracted using the golem-wasm-ast crate.

Host and stub mode

The golem-wasm-rpc crate can be both used in host and guest environments:

To compile the host version:

cargo build -p golem-wasm-rpc --no-default-features --features host

To compile the guest version, has minimal dependencies and feature set to be used in generated stubs:

cargo component build -p golem-wasm-rpc --no-default-features --features stub

Feature flags

  • arbitrary adds an Arbitrary instance for Value
  • bincode adds Bincode codecs for some types
  • host-bindings enables WIT-generated types for wasmtime hosts
  • json adds conversion functions for mapping of a WIT value and type definition to/from JSON
  • poem_openapi adds poem OpenAPI type class instances for some of the types
  • protobuf adds the protobuf message types
  • serde adds serde JSON serialization for some of the types
  • text enables wasm-wave based text representation for values
  • wasmtime adds conversion to wasmtime Val values
  • host enables all features: arbitrary, bincode, host-bindings, json, poem_openapi, protobuf, serde, text, typeinfo, and wasmtime
  • stub is to be used in generated WASM stubs and disables all features, and generates guest bindings instead of host bindings

Dependencies

~2–23MB
~335K SLoC