-
Notifications
You must be signed in to change notification settings - Fork 61
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
Support Serde for the built-in types #407
Comments
Can you expand on what this will allow you to do that you cannot do today? If this library serializes one specific
You'll need to be specific about exactly which types would be useful. |
Are you referring to the UTF-8 encoding issue when converting from OsStr to str? If so, I believe there are already several secure character conversion crates available, or you can implement a custom closure-based conversion interface. Actually, here's the situation: I'm working on writing a Tauri app, so naturally, I would like to display as complete error information as possible when I activate the console. Instead of logging in both the Rust and JavaScript sides, I would prefer if all the exposable built-in types could be converted into JSON, if possible. I have looked at the source code, and it seems that many of them only require adding a #derive. However, it is currently a bit cumbersome to manually implement this outside the crate, and it makes the code appear much more chaotic. |
No, I am not. My point is that you asked for
Right, here's more context. You don't just want something that can be serialized and deserialized, but you want something that can be serialized to JSON with a fixed and known serialization because you want to deserialize it outside of Rust. Although it'd be supremely annoying, I could make it so that every time you compile the library the serialized field names changed, which I'd guess would not be acceptable to you, but would still allow roundtrip serialization/deserialization in a single process.
Serialization is easy to add thanks to derive macros, but that doesn't mean that long-term support for serialized data is any easier. Serialization is another form of external interface that has to be carefully managed. For example, is it acceptable for the serialized form to change in a semver-compatible version? Do people expect that you can serialize a type with SNAFU 0.0.1 and then deserialize it later with SNAFU 0.1.0? That JSON could easily be written into a file and then loaded in a year.
Again, please list exactly which types you are talking about. |
From a more positive standpoint, Even today, you could achieve this today by creating your own |
Yes, actually, this is a minor issue. I have carefully reviewed the documentation and it seems that the only type that may need to be exposed is Location. As for Backtrace, it would be even better if it could be serialized as an array. This way, it could potentially be combined with frontend code to achieve more pretty logs, such as if someone want to create a specific debug tool. However, in most cases, using strings should be sufficient. |
This library doesn't really control In a few versions, when the version support lines up, SNAFU will probably drop the shim and inert versions and just default to the standard library version and maybe allow swapping to the backtrace crate.
For example, that's not yet stable. |
For example, Location. While it is possible to customize the serialization and deserialization process, it can become messy when it needs to be written in every place. It would be great if it could be a built-in feature.
The text was updated successfully, but these errors were encountered: