Decouple Error from Str::Repr

It was misleading to use Str (which ordinarily represents borrowed
strings) also for owned error messages.
diff --git a/gen/src/write.rs b/gen/src/write.rs
index 25f1b0b..8de422d 100644
--- a/gen/src/write.rs
+++ b/gen/src/write.rs
@@ -315,6 +315,25 @@
         writeln!(out, "}};");
     }
 
+    if needs_rust_error {
+        out.begin_block("namespace repr");
+        writeln!(out, "struct PtrLen final {{");
+        writeln!(out, "  const char *ptr;");
+        writeln!(out, "  size_t len;");
+        writeln!(out, "}};");
+        out.end_block("namespace repr");
+
+        writeln!(out, "class impl final {{");
+        writeln!(out, "public:");
+        writeln!(out, "  static Error error(repr::PtrLen ptrlen) noexcept {{");
+        writeln!(out, "    Error error;");
+        writeln!(out, "    error.msg = ptrlen.ptr;");
+        writeln!(out, "    error.len = ptrlen.len;");
+        writeln!(out, "    return error;");
+        writeln!(out, "  }}");
+        writeln!(out, "}};");
+    }
+
     out.end_block("namespace cxxbridge05");
 
     if needs_trycatch {
@@ -685,7 +704,7 @@
     indirect_call: bool,
 ) {
     if sig.throws {
-        write!(out, "::rust::Str::Repr ");
+        write!(out, "::rust::repr::PtrLen ");
     } else {
         write_extern_return_type_space(out, &sig.ret);
     }
@@ -823,7 +842,7 @@
         }
     }
     if sig.throws {
-        write!(out, "::rust::Str::Repr error$ = ");
+        write!(out, "::rust::repr::PtrLen error$ = ");
     }
     write!(out, "{}(", invoke);
     if sig.receiver.is_some() {
@@ -871,7 +890,7 @@
     writeln!(out, ";");
     if sig.throws {
         writeln!(out, "  if (error$.ptr) {{");
-        writeln!(out, "    throw ::rust::Error(error$);");
+        writeln!(out, "    throw ::rust::impl::error(error$);");
         writeln!(out, "  }}");
     }
     if indirect_return {