diff --git a/.gitignore b/.gitignore
index cabfbbc..18b2942 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ test_types_gen_project
test_map_gen_project
test_grpc_project
artifacts/
+temp_test_project/
diff --git a/Cargo.lock b/Cargo.lock
index bf461d3..bba7556 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1352,6 +1352,23 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
+[[package]]
+name = "temp_test_project"
+version = "0.1.0"
+dependencies = [
+ "bytes",
+ "futures-util",
+ "http",
+ "http-body",
+ "http-body-util",
+ "roto-codegen",
+ "roto-runtime",
+ "roto-tonic",
+ "tokio-stream",
+ "tonic",
+ "tower 0.4.13",
+]
+
[[package]]
name = "tempfile"
version = "3.27.0"
diff --git a/Cargo.toml b/Cargo.toml
index 422753a..be7fc0d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,6 +5,7 @@ members = [
"protos",
"benches",
"roto-tonic",
+ "temp_test_project",
"examples/hello_world",
]
diff --git a/codegen/helloworld.desc b/codegen/helloworld.desc
new file mode 100644
index 0000000..aa9c185
Binary files /dev/null and b/codegen/helloworld.desc differ
diff --git a/codegen/src/generator.rs b/codegen/src/generator.rs
index 55c6b1b..1697149 100644
--- a/codegen/src/generator.rs
+++ b/codegen/src/generator.rs
@@ -51,7 +51,7 @@ fn map_type_to_rust_accessor(field_type: i32, label: i32, is_map: bool) -> (Stri
match field_type {
9 => (
"&'a str".to_string(),
- "str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)".to_string(),
+ "std::str::from_utf8(bytes).map_err(|_| roto_runtime::RotoError::WireFormatViolation)".to_string(),
"\"\"".to_string(),
), // TYPE_STRING
1 => (
@@ -117,7 +117,7 @@ fn write_enum(enum_proto: &EnumDescriptorProto, output: &mut String) {
let accessor =
ProtoAccessor::new(val_data).expect("Failed to parse EnumValueDescriptorProto");
let (name_bytes, _) = accessor.get_value(1).expect("Enum value name missing");
- let name = str::from_utf8(name_bytes).expect("Enum value name invalid utf8");
+ let name = std::str::from_utf8(name_bytes).expect("Enum value name invalid utf8");
let (num_bytes, _) = accessor.get_value(2).expect("Enum value number missing");
let (num, _) =
roto_runtime::read_varint(num_bytes).expect("Enum value number invalid varint");
@@ -147,7 +147,7 @@ fn write_enum(enum_proto: &EnumDescriptorProto, output: &mut String) {
let accessor =
ProtoAccessor::new(val_data).expect("Failed to parse EnumValueDescriptorProto");
let (name_bytes, _) = accessor.get_value(1).expect("Enum value name missing");
- let name = str::from_utf8(name_bytes).expect("Enum value name invalid utf8");
+ let name = std::str::from_utf8(name_bytes).expect("Enum value name invalid utf8");
let (num_bytes, _) = accessor.get_value(2).expect("Enum value number missing");
let (num, _) =
roto_runtime::read_varint(num_bytes).expect("Enum value number invalid varint");
@@ -170,6 +170,7 @@ fn write_enum(enum_proto: &EnumDescriptorProto, output: &mut String) {
fn write_message(msg_proto: &DescriptorProto, output: &mut String) {
let msg_name = to_pascal_case(msg_proto.name().unwrap());
+ let mod_name = to_snake_case(msg_proto.name().unwrap());
let mut fields_info = Vec::new();
for field_res in msg_proto.field() {
@@ -332,10 +333,12 @@ fn write_message(msg_proto: &DescriptorProto, output: &mut String) {
let pascal_oneof_name = to_pascal_case(oneof_name);
let snake_oneof_name = to_snake_case(oneof_name);
- output.push_str(&format!(
- " pub fn which_{}(&self) -> roto_runtime::Result