pw_rpc: Move server/client calls to separate files
- Move the server/client calls to improve code organization and make
upcoming lock annotations simpler, since the Endpoint class is fully
defined in the server/client call headers.
- No longer have the server respond to a cancel for an unknown call.
There is no point in sending an error for that RPC to the client
because the client cancelled it and won't know about that call by the
time it gets the error. In general, error packets should only be sent
when an RPC fails to start or needs to be terminated.
- Use PW_TRY_ASSIGN in the server and client.
Change-Id: I467d06ef7139a5698be0b30e9ed1bac3a625e02e
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66201
Commit-Queue: Wyatt Hepler <hepler@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
diff --git a/pw_rpc/server_call.cc b/pw_rpc/server_call.cc
new file mode 100644
index 0000000..2308074
--- /dev/null
+++ b/pw_rpc/server_call.cc
@@ -0,0 +1,29 @@
+// Copyright 2021 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+#include "pw_rpc/internal/server_call.h"
+
+namespace pw::rpc::internal {
+
+ServerCall& ServerCall::operator=(ServerCall&& other) {
+ MoveFrom(other);
+
+#if PW_RPC_CLIENT_STREAM_END_CALLBACK
+ on_client_stream_end_ = std::move(other.on_client_stream_end_);
+#endif // PW_RPC_CLIENT_STREAM_END_CALLBACK
+
+ return *this;
+}
+
+} // namespace pw::rpc::internal