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 need to parse log of protobuf messages, generated by {:?}, back into protobuf objects, to replay messages. I forked RON deserializer, and made few changes to be able to deserialize {:?} representation. However, I cannot deserialize prost objects, because they use i32 instead of enum to represent enum, so information about actual type of field is lost. Unfortunately, this is limitation of Rust language itself. I hope, it will be fixed soon when RFC 2008 #[non_exhaustive] will be implemented and will work properly for #[repr(C)] enum's.
prost already generates is_valid() method for enum's, so it will not be hard to add generic union, use it instead of i32, and implement IsValidEnum trait for every protobuf enum.
The text was updated successfully, but these errors were encountered:
I need to parse log of protobuf messages, generated by {:?}, back into protobuf objects, to replay messages. I forked RON deserializer, and made few changes to be able to deserialize {:?} representation. However, I cannot deserialize prost objects, because they use i32 instead of enum to represent enum, so information about actual type of field is lost. Unfortunately, this is limitation of Rust language itself. I hope, it will be fixed soon when RFC 2008 #[non_exhaustive] will be implemented and will work properly for #[repr(C)] enum's.
As workaround, I propose to use union(enum, i32) instead of plain i32, to save information about type. My proof of concept can be found here:
https://play.rust-lang.org/?gist=6131d0fcadd0bf2bba48a3efe26278f0
prost already generates is_valid() method for enum's, so it will not be hard to add generic union, use it instead of i32, and implement IsValidEnum trait for every protobuf enum.
The text was updated successfully, but these errors were encountered: