Open mmaz opened 11 years ago
My current workaround is to explicitly match on each type. Using the above as an example again:
val bus = new EventBus()
val om = OneMessage.parseFrom(bytes)
List(om.foo, om.bar, om.baz).flatten.map(bus.post)
This works, but it is a bit more laborious when the protobuf definition changes
You can propose a solution that doesn't impact the generated code size too much and if it sounds good, I'll implement it.
I'm not sure but I think you can maybe use the Shapeless library to treat case classes as functional constructs. Maybe some sort of direct support for Shapeless could be added as well.
Is there an idiomatic way in ScalaBuff for deserializing a union-type container? This would obviate the need for protocol buffer reflection via
getAllFields
with Java-generated classes. For example, using OneMessage from the protocol buffer documentation :