-
Notifications
You must be signed in to change notification settings - Fork 15.9k
Description
Hello,
I'm trying to compile proto2 file to Ruby (using "protoc --ruby_out=...") and get this error:
Extensions are not yet supported for proto2 .proto files.
I've found this issue that seems to be related but it's still open (from 2016).
Few questions:
-
Are there any plans to support extensions for proto2 in Ruby?
-
I'm not very familiar with protobuf, but I read that the challenge is to support it in the DSL. Assuming that I don't use these fields of the extensions, is it an option to support telling the compiler to skip it in the generated Ruby models but support encoding to bytes with those fields as empty?
-
More than that, I'm actually only interested in encoding. Is there any way to encode Ruby hash to bytes based on proto definition without having the model in the middle? E.g, something like:
encode_to_bytes('Proto.MyTestMessage', { field1: 42 })
Instead of:
msg = Proto::MyTestMessage.new(field1: 42) Proto::MyTestMessage.encode(msg)
There's actually a JS tool called protobuf.js that generates a JSON descriptors file from proto file and allows exactly that, so if someone knows of a tool that can encode Ruby hashes to bytes based on JSON descriptors I'd love to hear.
Thanks!