stepancheg / rust-protobuf

Rust implementation of Google protocol buffers
MIT License
2.79k stars 380 forks source link

Support Any in text_format. #628

Open semtexzv opened 2 years ago

semtexzv commented 2 years ago

Given the proto:

syntax = "proto3";
package api;

import "google/protobuf/any.proto";

message Meta {

}

message Object {
  google.protobuf.Any object = 1;
}

message Service {
  Meta meta = 1;
  string descr = 2;
}

I would like to work with textprotos in following format:

# proto-file: api.proto
# proto-message: Object

object {
  [type.googleapis.com/api.Service] {
    meta { }
    descr: "Example"
  }
}

Current implementation does not support Any notation at all. This notation is outlined in the spec.

Implementation notes

Implementation will probably require introducing a context into the deserialization process. The context will need to contain a registry of known types.

stepancheg commented 2 years ago

I don't have time to work on it, but PR is welcome.