From 74d975788bf2f42216fa347db9fe4fa49eb2dcfe Mon Sep 17 00:00:00 2001 From: charles Date: Sun, 3 May 2026 21:03:55 -0700 Subject: [PATCH] add: files --- src/bin/protoc-gen-roto.rs | 5 +++-- src/generator.rs | 14 ++++++++------ src/lib.rs | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/bin/protoc-gen-roto.rs b/src/bin/protoc-gen-roto.rs index f0f111c..b06fb59 100644 --- a/src/bin/protoc-gen-roto.rs +++ b/src/bin/protoc-gen-roto.rs @@ -1,9 +1,10 @@ use env_logger::init; use log::{error, info}; use roto::generator::generate_rust_code; -use roto::proto_gen::google::protobuf::descriptor::{ - CodeGeneratorRequest, CodeGeneratorResponse, FileDescriptorSet, ResponseFile, +use roto::google::protobuf::descriptor::{ + FileDescriptorSet }; +use roto::google::protobuf::compiler::plugin::{CodeGeneratorRequest, CodeGeneratorResponse}; use roto::ProtoBuilder; use std::io::{self, Read, Write}; diff --git a/src/generator.rs b/src/generator.rs index e7734ae..561ffc3 100644 --- a/src/generator.rs +++ b/src/generator.rs @@ -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); diff --git a/src/lib.rs b/src/lib.rs index 945519f..0bb962f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ pub mod proto_gen; pub mod generator; +pub mod google; // Uncomment this to check if the code compiles // #[path = "../proto/google/protobuf/descriptor.rs"] // pub mod descriptor;