Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rs] pack and unpack functionality #25

Open
rvolosatovs opened this issue Apr 29, 2024 · 0 comments
Open

[rs] pack and unpack functionality #25

rvolosatovs opened this issue Apr 29, 2024 · 0 comments
Labels
enhancement New feature or request rust wRPC Rust support

Comments

@rvolosatovs
Copy link
Member

rvolosatovs commented Apr 29, 2024

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<T> are encoded as option::some variant of option<T>
    • resolved streams stream<T> are encoded as chunk_count:<core:uN> (chunk:<vec<T>>)^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 formalize component value definitions WebAssembly/component-model#336 Binary.md

cc @protochron

@rvolosatovs rvolosatovs added the enhancement New feature or request label Apr 29, 2024
@rvolosatovs rvolosatovs moved this to Backlog in wRPC 1.0.0 Apr 29, 2024
@rvolosatovs rvolosatovs moved this from Backlog to Blocked in wRPC 1.0.0 May 15, 2024
@rvolosatovs rvolosatovs added the rust wRPC Rust support label May 15, 2024
@rvolosatovs rvolosatovs removed this from wRPC 1.0.0 May 15, 2024
@rvolosatovs rvolosatovs changed the title pack and unpack functionality [rs] pack and unpack functionality May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rust wRPC Rust support
Projects
None yet
Development

No branches or pull requests

1 participant