Questions tagged [proto3]

Protocol Buffers - Google's data interchange format

Google Protocol Buffers questions related to version 3 of the Protocol Buffer format should be tagged with this tag.

At this time proto3 is still in alpha stage.

About Versioning

When protobuf was initially opensourced it implemented Protocol Buffers language version 2 (aka proto2), which is why the version number started from v2.0.0. From v3.0.0, a new language version (proto3) is introduced while the old version (proto2) will continue to be supported.

146 questions
1
vote
0 answers

Is there a way to recursively get all FieldDescriptors in protobuf?

I am trying to implement a way to check if all nontrivial fields in proto3 message are set (since presence is not encoded for trivial types like int). I have code like this namespace pb = google::protobuf; bool HasAll(const pb::Message& msg) { …
NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277
1
vote
2 answers

Is there a way to have an array of multiple types in proto3?

I want to design a proto3 message from this Cesium class:Cesium Class. It is an array containing [string, double, double, double]. Is there anyway to do this?
1
vote
1 answer

Can I use proto2 generated code stubs with libprotobuf3.x?

I have a legacy application using proto2 with libprotobuf2.x. There is another application application that I would like this application to talk to with proto3. I checked on possible solutions and the discussion in this thread says that…
1
vote
1 answer

More efficient way to set a oneof request in gRPC/proto3

Having this proto3 schema on a PHP client and Python server: service GetAnimalData{ rpc GetData (AnimalRequest) returns (AnimalData) {} } message AnimalRequest { OneOfAnimal TypeAnimal = 1; } message AnimalData { repeated int32 data =…
Lloen
  • 68
  • 4
  • 11
1
vote
1 answer

What is the purpose of --plugin parameter in protoc command

I am currently working in Protobuf part, and using protoc compiler to compile .proto file to java classes. In this command we have a paramter called 'plugin' used as --plugin=EXECUTABLE. I went through official documentation which says Specifies a…
abhilash_goyal
  • 711
  • 1
  • 10
  • 31
1
vote
1 answer

Protobuf ShortDebugString() crash

I have the following proto: syntax = "proto3"; package pb; message FooBar { string foo = 1; string bar = 2; } message FooBarList { repeated FooBar foobar = 1; } I just populate the repeated list with 2 values and try to print it as…
codentary
  • 993
  • 1
  • 14
  • 33
1
vote
0 answers

Passing a service in protobuf

Suppose, I have a Base class and a Foo class derived from Base: class Base { } class Foo : Base { } I'm writing the protobuf protocol to use their methods. They share some functionality, is there a way to avoid rewriting code by passing the…
1
vote
0 answers

Passing a class to an RPC in gRPC (proto3)

I recently installed gRPC (C++), and I have a question regarding the .proto files. Suppose that I want one of the members of the Request to be a custom user defined C++ class, maybe like so: message clientRequest { userClass user_class = 1; …
Test Zero
  • 35
  • 1
  • 4
1
vote
1 answer

proto3 - oneof vs fields with identifier

I am writing a proto3 class for an object which currently have around 2 variations, and will grow up to 6 or 7. Only one of them would be used in a message. These variations do not share common fields. They will be encoded as a submessage in a…
Termin4t0r
  • 199
  • 3
  • 10
1
vote
1 answer

How to add interface and class in proto 3 payload in gRPC communication

I need to write a framework and there are two app which are communicating using gRPC. They share some common proto payload. Now, challenge is this, I want to write some interface and implementation in that proto3 proto contract.It is c# based app so…
Yogesh
  • 3,044
  • 8
  • 33
  • 60
1
vote
2 answers

How to read a proto3 custom option from Java

Given the following service: message Message { string content = 1; } service EchoService { rpc echo (Message) returns (Message) { option (google.api.http) = { get: "/echo" }; } } I want to read the option from Java. My understand is the…
Cheetah
  • 13,785
  • 31
  • 106
  • 190
1
vote
1 answer

How can I reserve all values of an enum in proto3?

I have a field of an enum type that I would like to deprecate. No clients use this field or its enum type. I want to reserve all of the values in this enum so that it cannot be reused. message Example { ... enum Foo { BAR = 0; …
cascal
  • 2,943
  • 2
  • 17
  • 19
1
vote
1 answer

Is it possible to include vector fields in a protobuf message to generate Rust struct?

I have a protobuf file used to generate types in a project. One of the types looks like: syntax = "proto3"; // ... message myStruct { int32 obj_id = 1; string obj_code = 2; string obj_name = 3; // ... some more fields } // ...…
m.raynal
  • 2,983
  • 2
  • 21
  • 34
1
vote
0 answers

how to assign repeated message in protobuf-php, with proto3 syntax?

The .proto file defined: message ResponseStatus { uint32 code = 1; string message = 2; } message DepositPaymentRequest { uint32 member_id = 1; } message DepositPaymentResponse { ResponseStatus status = 1; repeated DepositMethod…
Tank
  • 11
  • 2
1
vote
1 answer

Intialise protocol buffers in single expression

I'm using protocol buffers in .net, and generating C# classes using protoc. For example, lets take this proto3 file from https://developers.google.com/protocol-buffers/docs/proto3: message SearchResponse { repeated Result results = 1; } message…
Yair Halberstadt
  • 5,733
  • 28
  • 60