English 中文(简体)
如何设计未来的礼宾缓冲附加价值?
原标题:How to design for a future additional enum value in protocol buffers?

礼宾缓冲的吸引力在于,它允许你在不打破使用旧定义的密码的情况下扩大电文定义。 https://developers.google.com/protocol-buffers/docs/proto#enum>。

a field with an enum type can only have one of a specified set of constants as its value (if you try to provide a different value, the parser will treat it like an unknown field)

因此,如果你延长总价值并使用新价值,那么如果存在新价值,旧法典中具有这种价值的领域将不明确或具有违约价值。

什么是处理这一问题的良好战略,知道今后可能还会增加其他价值?

一种思维方式是界定“未定义的”遗体成员,并规定违约时,旧的法典将知道它已经发出可以解释的内容。 这是否明智,是否有更好的办法处理这种情况?

最佳回答

是的,最佳办法是使图象中的首份数值达到。 然后,一些老方案阅读了一种价值很高的图纸,它们不承认它为UNKNOWN,希望它们能够合理地处理这一内容,例如通过绕过这一要素。

If you want to do this you ll also want to make the enum be optional not required.

<>注:它必须是在<>/em>上宣布的第一种价值——只是零值才导致违约。

问题回答




相关问题
Serializing a List of objects using Protobuf-net

I ve been looking to do some binary serialization to file and protobuf-net seems like a well-performing alternative. I m a bit stuck in getting started though. Since I want to decouple the definition ...

How to use protocol buffers?

Could someone please help and tell me how to use protocol buffers. Actually I want to exchange data through sockets between a program running on unix and anoother running on windows in order to run ...

Using Protocol buffer as general Data object?

We re introducing protocol buffers as the new transport for some back end RPC services. Because there s resistance to manually shuttling data between different forms of similar objects, I can forsee ...

Go integration with Protocol Buffers?

After a quick look at the documentation, I immediately started to think about integration with existing languages and applications and was wondering whether support would be provided for Protocol ...

Android and Protocol Buffers

I am writing an Android application that would both store data and communicate with a server using protocol buffers. However, the stock implementation of protocol buffers compiled with the LITE flag (...

热门标签