add: files

This commit is contained in:
2026-05-03 21:03:55 -07:00
parent 20e4fb909b
commit 74d975788b
3 changed files with 12 additions and 8 deletions
+8 -6
View File
@@ -1,6 +1,8 @@
use crate::proto_gen::google::protobuf::descriptor::{
DescriptorProto, EnumDescriptorProto, FieldDescriptorProto, FileDescriptorProto, FileDescriptorSet,
use crate::google::protobuf::descriptor::{
FileDescriptorSet, FieldDescriptorProto, DescriptorProto, EnumDescriptorProto, FileDescriptorProto
};
use crate::google::protobuf::compiler::plugin::{CodeGeneratorRequest, CodeGeneratorResponse};
use crate::{ProtoAccessor, Result, RotoError};
use std::str;
use std::collections::{HashMap, HashSet};
@@ -119,7 +121,7 @@ pub fn generate_rust_code(
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() {
@@ -150,7 +152,7 @@ pub fn generate_rust_code(
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");
@@ -185,7 +187,7 @@ pub fn generate_rust_code(
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));
@@ -303,7 +305,7 @@ pub fn generate_rust_code(
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);