Are there any conventions yet for formatting component-model-typed values to text? Like, a common way of rendering variant/result/flags/etc. to JSON, or some other format?
I've been working on this JSON repr: https://hackmd.io/@lann/rJFNJ2Mhn
I tried to follow web api conventions wrt e.g. result
s, which may make it a little odd-looking to some
How well do the representation of specialized types map to their despecialized equivalents as defined in e.g. the Canonical ABI doc?
Not well; I prioritized concision and some broad "JSON conventionality"
Note though that WIT itself can't represent all of the despecialized equivalents since several of them use numeric field/variant labels.
I have an initial implementation of the above serialization format: https://github.com/lann/wasmtime-component-serde
Cool!
Perhaps at some point we should move wasmtime::component::{Type, Val}
out into a separate crate so that tools like this can use them without pulling in all of wasmtime
You currently can't construct recursively-defined Type
s without instantiating a (dummy) component either.
At least not via publicly documented interfaces that I've seen.
I had to resort to this and this to test complex types.
I'm a little surprised serde-json doesn't handle things like serializing big numbers or Infinity into strings automatically. I think that means that the comment is right; we may eventually need different serde serializations for different backends.
wrt moving component::{Type, Val} out to a separate crate, it would also be really cool if we could move the Lift, Lower, ComponentVal
traits as well, so that wasmtime-wit-bindgen wouldnt actually imply a dependency on wasmtime unless the user wants it. that would let us make wasmtime-wasi work across runtimes again
well, again as in, like wasi-common did before i got rid of lucet compatibility in wiggle.
i believe the story was that wasm3 was using wasi-common somewhere? tbh i cant remember who reported they were sad that i broke it
but idk, maybe the counter-argument is that ComponentVal is a huge chunk of the component runtime's complexity and it cant be extracted. i havent tried to do it.
Last updated: Dec 23 2024 at 13:07 UTC