49 releases (8 stable)

1.0.7 Oct 23, 2024
1.0.3 Sep 23, 2024
0.0.41 Aug 14, 2024
0.0.36 Jul 31, 2024
0.0.16 Mar 30, 2024

#133 in WebAssembly

Download history 441/week @ 2024-07-29 559/week @ 2024-08-05 925/week @ 2024-08-12 1381/week @ 2024-08-19 696/week @ 2024-08-26 453/week @ 2024-09-02 446/week @ 2024-09-09 260/week @ 2024-09-16 377/week @ 2024-09-23 40/week @ 2024-09-30 511/week @ 2024-10-07 378/week @ 2024-10-14 393/week @ 2024-10-21 229/week @ 2024-10-28 60/week @ 2024-11-04 46/week @ 2024-11-11

752 downloads per month
Used in 10 crates

Apache-2.0

400KB
8K 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 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 wasm-rpc --no-default-features --features stub

Feature flags

  • arbitrary adds an Arbitrary instance for Value
  • json adds conversion functions for mapping of a WIT value and type definition to/from JSON
  • protobuf adds the protobuf message types
  • wasmtime adds conversion to wasmtime Val values
  • host enables all features: arbitrary, json, protobuf, 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

~6–26MB
~395K SLoC