35 releases

new 0.0.35 Jul 17, 2024
0.0.34 Jul 15, 2024
0.0.33 Jun 26, 2024
0.0.22 Apr 19, 2024
0.0.7 Feb 23, 2024

#274 in WebAssembly

Download history 578/week @ 2024-03-26 418/week @ 2024-04-02 614/week @ 2024-04-09 703/week @ 2024-04-16 129/week @ 2024-04-23 59/week @ 2024-04-30 199/week @ 2024-05-07 166/week @ 2024-05-14 45/week @ 2024-05-21 134/week @ 2024-05-28 484/week @ 2024-06-04 699/week @ 2024-06-11 1025/week @ 2024-06-18 778/week @ 2024-06-25 404/week @ 2024-07-02 510/week @ 2024-07-09

2,728 downloads per month
Used in 7 crates

Apache-2.0

360KB
7.5K 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

~3–19MB
~269K SLoC