How to know whether the currently processed file is proto2 or proto3 in CustomizeCallback?
Closed this issue · 1 comments
ape-casear commented
I need to add custom annotations to some fields. I found out that in the output of the rs code. Specifically serde
.
the value would be wrapped by Option
if it is in proto2
// proto2
foo: ::std::option::Option<u32>
// proto3
foo: u32
so params in the handler fn should be determined by syntax proto 2 or 3?
How to know whether the currently processed file is proto2 or proto3 in CustomizeCallback?
ape-casear commented
got it
fn field(&self, field: &FieldDescriptor) -> Customize {
let msg = field.containing_message();
let syntax = msg.file_descriptor().proto().syntax();
println!("syntax is {}", syntax);