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
}
// ... some more message, enum, etc ....
Then I can launch a tiny script that generates some Go code though protoc-gen-go
, that gets later translated into Rust though another script using protoc-gen-rust
.
The result is a Rust file that looks like:
// This file is generated by rust-protobuf 2.0.0. Do not edit
// @generated
// ...
pub struct myStruct {
// message fields
pub obj_id: i32,
pub obj_code: ::std::string::String,
pub obj_name: ::std::string::String,
// ... some more fields
}
impl myStruct {
// ... lots of constructors, getters, setters, etc
}
I don't want a better way to do generate the Rust types altogether, the project is massive and in prod, my job is not to rewrite/reorganize it but just to add some functionalities, for which I need some nice little vectors of flags to be added in a couple of structures.
I'd like to add some Vec
fields in the myStruct
struct, like those:
pub struct myClass {
// ... some fields like obj_id etc ...
// the fields I want to add
bool_vec: Vec<bool>,
bool_vec_vec: Vec<Vec<bool>>,
// ...
}
Is it possible to do so using the proto-buf thing, or not? If yes, how can I do it?