Wasm Wave support for encoding & decoding values #1053
Merged
+2,525
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, reading (
read_value) and writing values (tokio_util::codec::Encoder) is only supported for wasmtimeI want to be able to easily use wRPC from the command line (which wasm-wave is designed to enable), but I want to do this without having to convert to wasmtime as an intermediate step (so that it's runtime agnostic)
I felt like maybe the right way to do this is to add a
wrpc-wavecrate to wrpc (in the same way there is awrpc-runtime-wasmtime)Benefits
This makes wRPC easily usable from wasm-wave. This helps not just with CLI / string-based cases, but also wasm-wave has a generic
WasmValueandWasmTypetrait that any runtime can implement (in fact, wasmtime implements this!)This means that if somebody wants to add another runtime to wRPC, they can get at least partial support if their runtime already supports wasm-wave
Downsides
This PR includes we feels like somewhat duplicate code. Notably,
crates/wave/src/corecontains logic that very closely overlaps withwrpc-runtime-wasmtime. This means that any time you update one, you have to remember to update the other (although I don't suspect these encoding/decoding functions will change often)We can't easily deduplicate because:
It may be possible to deduplicate part of the code with some kind of shared utility crate or something like that, but I wasn't sure which approach you'd prefer