add: files
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
use env_logger::init;
|
use env_logger::init;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use roto::generator::generate_rust_code;
|
use roto::generator::generate_rust_code;
|
||||||
use roto::proto_gen::google::protobuf::descriptor::{
|
use roto::google::protobuf::descriptor::{
|
||||||
CodeGeneratorRequest, CodeGeneratorResponse, FileDescriptorSet, ResponseFile,
|
FileDescriptorSet
|
||||||
};
|
};
|
||||||
|
use roto::google::protobuf::compiler::plugin::{CodeGeneratorRequest, CodeGeneratorResponse};
|
||||||
use roto::ProtoBuilder;
|
use roto::ProtoBuilder;
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -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 crate::{ProtoAccessor, Result, RotoError};
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
@@ -119,7 +121,7 @@ pub fn generate_rust_code(
|
|||||||
enum_name
|
enum_name
|
||||||
));
|
));
|
||||||
|
|
||||||
let mut values = enum_proto.enum_value();
|
let mut values = enum_proto.value();
|
||||||
let mut variant_count = 0;
|
let mut variant_count = 0;
|
||||||
let mut zero_variant_name = None;
|
let mut zero_variant_name = None;
|
||||||
while let Some(val_res) = values.next() {
|
while let Some(val_res) = values.next() {
|
||||||
@@ -150,7 +152,7 @@ pub fn generate_rust_code(
|
|||||||
enum_name
|
enum_name
|
||||||
));
|
));
|
||||||
|
|
||||||
let mut values = enum_proto.enum_value();
|
let mut values = enum_proto.value();
|
||||||
while let Some(val_res) = values.next() {
|
while let Some(val_res) = values.next() {
|
||||||
let (val_data, _) = val_res.expect("Failed to read enum value");
|
let (val_data, _) = val_res.expect("Failed to read enum value");
|
||||||
let accessor = ProtoAccessor::new(val_data).expect("Failed to parse EnumValueDescriptorProto");
|
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 field_name = field_proto.name().unwrap();
|
||||||
|
|
||||||
let tag = field_proto.number().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;
|
let f_label = field_proto.label().unwrap() as i32;
|
||||||
|
|
||||||
fields_info.push((field_name.to_string(), tag, f_type, f_label));
|
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 safe_name = if field_name == "type" { format!("r#{}", field_name) } else { field_name.to_string() };
|
||||||
|
|
||||||
let tag = field_proto.number().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 (rust_type, method) = map_type_to_rust_builder(f_type);
|
let (rust_type, method) = map_type_to_rust_builder(f_type);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
pub mod proto_gen;
|
pub mod proto_gen;
|
||||||
pub mod generator;
|
pub mod generator;
|
||||||
|
pub mod google;
|
||||||
// Uncomment this to check if the code compiles
|
// Uncomment this to check if the code compiles
|
||||||
// #[path = "../proto/google/protobuf/descriptor.rs"]
|
// #[path = "../proto/google/protobuf/descriptor.rs"]
|
||||||
// pub mod descriptor;
|
// pub mod descriptor;
|
||||||
|
|||||||
Reference in New Issue
Block a user