Open danleh opened 1 year ago
At this time there's no support for using io::Write
, it's required to use a Vec<u8>
. Would it work for your use case to consider the Vec<u8>
a form of BufWriter
where it's periodically flushed, e.g. between sections or between functions?
Sure, that would work for me.
I was more wondering what the reason for the separate Encode
trait is, and whether it could be replaced by the standard io::Write
.
The Encode
trait is necessary to indicate "write yourself into this thing with the wasm encoding" and the choice of taking Vec<u8>
vs io::Write
was mostly a result of me to cut down on the size of compiled and monomorphized code. Dealing with errors in io::Write
can cause a lot of code bloat if used everywhere and not much in wasm is so big it can't fit in memory (was my thinking)
Thanks a lot, that makes sense and answers my question! I hadn't thought about code size before.
Similar to this prior question on streaming reading with
wasmparser
, I am wondering if it is possible to do streaming encoding withwasm-encoder
?Right now, the central trait seems to be
wasm_encoder::Encode
, which takes the sink as a&mut Vec<u8>
. Would it be possible to get rid of that trait and instead serialize to anyimpl io::Write
? That should strictly be more general, asio::Write
is already implemented in the standard library forVec<u8>
anyway.Thanks a lot for the great selection of crates!