Migrate to using generated code
This commit is contained in:
+9
-8
@@ -1,7 +1,8 @@
|
||||
|
||||
|
||||
use crate::proto_gen::google::protobuf::descriptor::{
|
||||
CodeGeneratorRequest, CodeGeneratorResponse, FileDescriptorSet, ResponseFile, DescriptorProto, EnumDescriptorProto, FileDescriptorProto, FieldDescriptorProto
|
||||
use crate::google::protobuf::descriptor::{
|
||||
DescriptorProto, EnumDescriptorProto, FileDescriptorProto, FieldDescriptorProto, FileDescriptorSet
|
||||
};
|
||||
use crate::google::protobuf::compiler::plugin::{
|
||||
CodeGeneratorRequest, CodeGeneratorResponse, code_generator_response::File,
|
||||
};
|
||||
use crate::{ProtoAccessor, Result, RotoError};
|
||||
use std::str;
|
||||
@@ -89,7 +90,7 @@ fn write_enum(enum_proto: &EnumDescriptorProto, output: &mut String) {
|
||||
enum_name
|
||||
));
|
||||
|
||||
let mut values = enum_proto.enum_value();
|
||||
let mut values = enum_proto.value();
|
||||
let mut variant_count = 0;
|
||||
let mut zero_variant_name = None;
|
||||
while let Some(val_res) = values.next() {
|
||||
@@ -120,7 +121,7 @@ fn write_enum(enum_proto: &EnumDescriptorProto, output: &mut String) {
|
||||
enum_name
|
||||
));
|
||||
|
||||
let mut values = enum_proto.enum_value();
|
||||
let mut values = enum_proto.value();
|
||||
while let Some(val_res) = values.next() {
|
||||
let (val_data, _) = val_res.expect("Failed to read enum value");
|
||||
let accessor = ProtoAccessor::new(val_data).expect("Failed to parse EnumValueDescriptorProto");
|
||||
@@ -151,7 +152,7 @@ fn write_message(msg_proto: &DescriptorProto, output: &mut String) {
|
||||
let field_name = field_proto.name().unwrap();
|
||||
|
||||
let tag = field_proto.number().unwrap();
|
||||
let f_type = field_proto.field_type().unwrap() as i32;
|
||||
let f_type = field_proto.r#type().unwrap() as i32;
|
||||
let f_label = field_proto.label().unwrap() as i32;
|
||||
|
||||
fields_info.push((field_name.to_string(), tag, f_type, f_label));
|
||||
@@ -240,7 +241,7 @@ fn write_message(msg_proto: &DescriptorProto, output: &mut String) {
|
||||
let field_name = field_proto.name().unwrap();
|
||||
let safe_name = if field_name == "type" { format!("r#{}", field_name) } else { field_name.to_string() };
|
||||
let tag = field_proto.number().unwrap();
|
||||
let f_type = field_proto.field_type().unwrap() as i32;
|
||||
let f_type = field_proto.r#type().unwrap() as i32;
|
||||
let (rust_type, method) = map_type_to_rust_builder(f_type);
|
||||
output.push_str(&format!(
|
||||
" pub fn {}(mut self, value: {}) -> crate::Result<Self> {{\n self.builder.{}({}, value)?;\n Ok(self)\n }}\n\n",
|
||||
|
||||
Reference in New Issue
Block a user