pw_rpc: Add Request/Response types for raw MethodInfo

Both pwpb and nanopb implementations define Request and Response types
in MethodInfo specialization. For raw they are marked as void to prevent
any ConstByteSpan shallow copying.

Change-Id: I262208406eb2af9d7460e1aa051f7dd2ed32b132
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/97905
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Pigweed-Auto-Submit: Dennis Kormalev <denk@google.com>
diff --git a/pw_rpc/py/pw_rpc/codegen_raw.py b/pw_rpc/py/pw_rpc/codegen_raw.py
index 15bc15b..56a9f83 100644
--- a/pw_rpc/py/pw_rpc/codegen_raw.py
+++ b/pw_rpc/py/pw_rpc/codegen_raw.py
@@ -133,6 +133,19 @@
 
         self.line('}')
 
+    def method_info_specialization(self, method: ProtoServiceMethod) -> None:
+        self.line()
+        # We have Request/Response as voids to mark raw as a special case.
+        # Raw operates in ConstByteSpans, which won't be copied by copying the
+        # span itself and without special treatment will lead to dangling
+        # pointers.
+        #
+        # Helpers/traits that want to use Request/Response and should support
+        # raw are required to do a special implementation for them instead that
+        # will copy the actual data.
+        self.line('using Request = void;')
+        self.line('using Response = void;')
+
 
 class StubGenerator(codegen.StubGenerator):
     def unary_signature(self, method: ProtoServiceMethod, prefix: str) -> str: