pw_rpc: Add default and move/assign constructors to ClientCall

This updates the BaseClientCall and NanopbClientCall classes to have
working default and move constructors. This allows client calls to be
declared statically, supporting asynchronous RPC calls.

Change-Id: I6bb153c0ae435708456291fe65d76fd0da26e94c
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/42729
Commit-Queue: Alexei Frolov <frolv@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
diff --git a/pw_rpc/base_client_call_test.cc b/pw_rpc/base_client_call_test.cc
index 7f15146..8ddf5e1 100644
--- a/pw_rpc/base_client_call_test.cc
+++ b/pw_rpc/base_client_call_test.cc
@@ -35,6 +35,26 @@
   EXPECT_EQ(context.client().active_calls(), 0u);
 }
 
+TEST(BaseClientCall, Move_UnregistersOriginal) {
+  ClientContextForTest context;
+  EXPECT_EQ(context.client().active_calls(), 0u);
+
+  BaseClientCall moved(&context.channel(),
+                       context.service_id(),
+                       context.method_id(),
+                       [](BaseClientCall&, const Packet&) {});
+  EXPECT_EQ(context.client().active_calls(), 1u);
+
+  BaseClientCall call(std::move(moved));
+  EXPECT_EQ(context.client().active_calls(), 1u);
+
+// Ignore use-after-move.
+#ifndef __clang_analyzer__
+  EXPECT_FALSE(moved.active());
+#endif  // __clang_analyzer__
+  EXPECT_TRUE(call.active());
+}
+
 class FakeClientCall : public BaseClientCall {
  public:
   constexpr FakeClientCall(rpc::Channel* channel,