unionproto.proto 631 B

1234567891011121314151617181920212223242526272829303132
  1. // This is an example of how to handle 'union' style messages
  2. // with nanopb, without allocating memory for all the message types.
  3. //
  4. // There is no official type in Protocol Buffers for describing unions,
  5. // but they are commonly implemented by filling out exactly one of
  6. // several optional fields.
  7. syntax = "proto2";
  8. message MsgType1
  9. {
  10. required int32 value = 1;
  11. }
  12. message MsgType2
  13. {
  14. required bool value = 1;
  15. }
  16. message MsgType3
  17. {
  18. required int32 value1 = 1;
  19. required int32 value2 = 2;
  20. }
  21. message UnionMessage
  22. {
  23. optional MsgType1 msg1 = 1;
  24. optional MsgType2 msg2 = 2;
  25. optional MsgType3 msg3 = 3;
  26. }