Conversation
IMO, the best way to do this would be to save every unknown value (of enums & unknown fields) in a type
Heya {.proto3.} = object
f {.fieldNumber: 1.}: int
otherFields: UnknownProtoFieldsIf the user cares about unknown enum values & field, he'll have to add it (and .proto parsing will always add it) This would kill two birds in one stone, wdyt @arnetheduck @lchenut ? |
|
So, the c++ proto3 behavior is to allow the fields to take on non-enum values - I would likely start with https://developers.google.com/protocol-buffers/docs/reference/cpp-generated#enum:
the proto2 behavior is indeed to treat the enum as an unknown field - one way to understand the difference vs proto3 is that this approach isn't great. That said, unknown field preservation is indeed a desireable feature in general so in proto2 we could potentially use this solution - I imagine we'd add some marker that says Because protobuf enums 99% work like const+int32 in nim, I kind of see this feature as one of the lower-priority things - a PbEnum solves this with a slightly better API but I wonder if it's too cumbersome in practice - perhaps |
|
Another thing for the todo list: conformance suite support - ie this feature was removed because it wasn't conforming to upstream, so we should do it right this time |
Things left to do:
For the last point, it might be hard with the way nim works with enum:
So for now, I set the enum at the default value if it isn't recognized.