You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm doing a rust program with webassembly “plugins” (a SMTP server, the code is available here). While doing so, there are -> std::io::Result<T> functions that I'd like to implement in webassembly, that may end up calling back into rust to perform IO.
However, in order to do that (be it “expose a -> std::io::Result<T> callback to wasm” or “expose a -> std::io::Result<T> callback from wasm”), I need to have a way to pass an std::io::Error to/from wasm, which basically means serialization (I currently use bincode semi-manually, though hopefully someday wasm-bindgen will support this use case directly).
Currently, what I do is pass a Result<T, String> and then rebuild with std::io::ErrorKind::Other, because I'd rather avoid having lines and lines of serialization boilerplate.
However, I'm thinking it may make sense to have serde already have implementations for std::io::Error as a (std::io::ErrorKind, String)? This is not a perfect identity (because it loses the potential for having raw os errors), but I'm thinking it should hopefully be good enough?
Related to #1480, though I think being able to (de)serialize std::io::Result is a lot less use-case-specific than just std::io::ErrorKind (although I'd guess it'd also solve that other use case as I suppose the implementation will most likely go through serializing ErrorKind)
Anyway, thank you for this awesome crate :)
The text was updated successfully, but these errors were encountered:
I'd prefer not to build this into the serde crate. But it would be possible for another crate to provide serialization/deserialization logic for std::io::Result that's usable through serde's serialize_with and deserialize_with attributes.
I understand! FWIW, I built https://crates.io/crates/serde-error in the meantime. To the best of my knowledge it is bug-free, feature-complete and not only used by me (though the download count makes me guess it's not highly used). So feel free to link to it should other people request it! :)
Hello!
I'm doing a rust program with webassembly “plugins” (a SMTP server, the code is available here). While doing so, there are
-> std::io::Result<T>
functions that I'd like to implement in webassembly, that may end up calling back into rust to perform IO.However, in order to do that (be it “expose a
-> std::io::Result<T>
callback to wasm” or “expose a-> std::io::Result<T>
callback from wasm”), I need to have a way to pass anstd::io::Error
to/from wasm, which basically means serialization (I currently use bincode semi-manually, though hopefully someday wasm-bindgen will support this use case directly).Currently, what I do is pass a
Result<T, String>
and then rebuild withstd::io::ErrorKind::Other
, because I'd rather avoid having lines and lines of serialization boilerplate.However, I'm thinking it may make sense to have serde already have implementations for
std::io::Error
as a(std::io::ErrorKind, String)
? This is not a perfect identity (because it loses the potential for having raw os errors), but I'm thinking it should hopefully be good enough?Related to #1480, though I think being able to (de)serialize
std::io::Result
is a lot less use-case-specific than juststd::io::ErrorKind
(although I'd guess it'd also solve that other use case as I suppose the implementation will most likely go through serializingErrorKind
)Anyway, thank you for this awesome crate :)
The text was updated successfully, but these errors were encountered: