Checkpoint for gRPC implementation

This commit is contained in:
2026-05-12 13:44:53 -07:00
parent 02a0b0d908
commit 804ff3ead0
12 changed files with 882 additions and 19 deletions
+4 -3
View File
@@ -439,14 +439,15 @@ fn write_message(msg_proto: &DescriptorProto, output: &mut String) {
output.push_str("}\n\n");
output.push_str(&format!("impl roto_runtime::RotoOwned for Owned{} {{\n", msg_name));
output.push_str(&format!(" type Reader<'a> = {}<'a>;\n", msg_name));
output.push_str(&format!(" fn reader(&self) -> {}<'_> {{\n", msg_name));
output.push_str(&format!(" {}::new(&self.data).expect(\"failed to create reader\")\n", msg_name));
output.push_str(" }\n");
output.push_str("}\n\n");
output.push_str(&format!("impl roto_runtime::RotoMessage for Owned{} {{\n", msg_name));
output.push_str(" fn decode(buf: bytes::Bytes) -> Self {\n");
output.push_str(&format!(" Owned{} {{ data: buf }}\n", msg_name));
output.push_str(" fn decode(buf: bytes::Bytes) -> roto_runtime::Result<Self> {\n");
output.push_str(&format!(" Ok(Owned{} {{ data: buf }})\n", msg_name));
output.push_str(" }\n\n");
output.push_str(" fn bytes(&self) -> bytes::Bytes {\n");
output.push_str(" self.data.clone()\n");
@@ -675,7 +676,7 @@ fn write_service(svc_proto: &ServiceDescriptorProto, output: &mut String) {
};
output.push_str(&format!(
" async fn {}(&self, request: {}) -> Result<{}, Status>;\n",
" async fn {}(&self, request: {}) -> std::result::Result<{}, Status>;\n",
method_name, req_type, resp_type
));
}
+1 -1
View File
@@ -58,7 +58,7 @@ fn test_generated_code_builds() {
let cargo_toml_content =
fs::read_to_string(&cargo_toml_path).expect("Failed to read Cargo.toml");
let updated_cargo_toml = format!(
"{}\n\nroto-codegen = {{ path = \"..\" }}\nroto-runtime = {{ path = \"../../runtime\" }}\n\n[workspace]\n",
"{}\n\nroto-codegen = {{ path = \"..\" }}\nroto-runtime = {{ path = \"../../runtime\" }}\nbytes = \"1.0\"\ntonic = \"0.12\"\ntokio-stream = \"0.1\"\n\n[workspace]\n",
cargo_toml_content
);
fs::write(cargo_toml_path, updated_cargo_toml).expect("Failed to write Cargo.toml");
+1 -1
View File
@@ -38,7 +38,7 @@ fn test_map_generated_code_builds() {
let cargo_toml_content =
fs::read_to_string(&cargo_toml_path).expect("Failed to read Cargo.toml");
let updated_cargo_toml = format!(
"{}\n\nroto-codegen = {{ path = \"..\" }}\nroto-runtime = {{ path = \"../../runtime\" }}\n\n[workspace]\n",
"{}\n\nroto-codegen = {{ path = \"..\" }}\nroto-runtime = {{ path = \"../../runtime\" }}\nbytes = \"1.0\"\ntonic = \"0.12\"\ntokio-stream = \"0.1\"\n\n[workspace]\n",
cargo_toml_content
);
fs::write(cargo_toml_path, updated_cargo_toml).expect("Failed to write Cargo.toml");