// for protobuf in rust use prost // https://github.com/tokio-rs/prost // write your protobuf file and then prost will convert it to rust // types for you message PhoneNumber { string number = 1; PhoneType type = 2; } // will become pub struct PhoneNumber { pub number: String, pub r#type: i32, // the `r#` is needed because `type` is a Rust keyword } impl PhoneNumber { pub fn r#type(&self) -> PhoneType { ... } pub fn set_type(&mut self, value: PhoneType) { ... } }