bytecodealliance / bytecodealliance/wrpc

[rs] `pack` and `unpack` functionality

Open
#25 1 comment 0 reactions 0 assignees View on GitHub
enhancement rust
Dominant language
Rust
Stars
336
Forks
47
Avg merge
2d 2h
Merged PRs (30d)
26

Description

wRPC values will always require a multiplexed connection and appropriate APIs for transmission and receival (due to values potentially containing nested async values, like streams or futures) - there may be use cases, however, where it may be desired to directly encode/decode wRPC values to/from single byte buffer - for example, for persistent storage. For those use cases, I propose to introduce `pack`/`unpack` functionality, which works the following way:

- All values can be *packed* - producing a single byte buffer with fully resolved/ready async values, if any
- *packed* values can always be *unpacked*
- Only fully resolved values can be *packed* (meaning that all incoming streams are fully received and finished and all futures are "ready" and their result is known). Packing operation may never complete if value being packed never resolves - therefore, packing operation MUST provide an API, which takes in a user-provided timeout.
- Just like in "core wRPC":
- resolved futures `future` are encoded as `option::some` variant of `option`
- resolved streams `stream` are encoded as `chunk_count: (chunk:>)^chunk_length` with or without the "end" 0-length chunk. The special case of a "ready" empty stream is encoded as a stream containing a single, empty chunk
- Encoding format is otherwise defined in https://github.com/WebAssembly/component-model/pull/336 `Binary.md`

cc @protochron

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.