pw_rpc: Replace raw synchronous unary methods with asynchronous
Remove uses of the raw synchronus unary API to prepare for removing
support for it. The raw synchronous unary API is no longer useful after
the removal of ChannelOutput::AcquireBuffer(). RPC implementations
should use the raw asynchronous unary API instead.
Change-Id: I71e25b6c769e894923abb3aeb9fdb2b82f74fb89
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/84920
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_file/flat_file_system.cc b/pw_file/flat_file_system.cc
index 0d822dd..48aaf69 100644
--- a/pw_file/flat_file_system.cc
+++ b/pw_file/flat_file_system.cc
@@ -124,7 +124,8 @@
EnumerateAllFiles(writer);
}
-StatusWithSize FlatFileSystemService::Delete(ConstByteSpan request, ByteSpan) {
+void FlatFileSystemService::Delete(ConstByteSpan request,
+ rpc::RawUnaryResponder& responder) {
protobuf::Decoder decoder(request);
while (decoder.Next().ok()) {
if (decoder.FieldNumber() !=
@@ -134,11 +135,13 @@
std::string_view file_name_view;
if (!decoder.ReadString(&file_name_view).ok()) {
- return StatusWithSize(Status::DataLoss(), 0);
+ responder.Finish({}, Status::DataLoss()).IgnoreError();
+ return;
}
- return StatusWithSize(FindAndDeleteFile(file_name_view), 0);
+ responder.Finish({}, FindAndDeleteFile(file_name_view)).IgnoreError();
+ return;
}
- return StatusWithSize(Status::InvalidArgument(), 0);
+ responder.Finish({}, Status::InvalidArgument()).IgnoreError();
}
Result<Entry*> FlatFileSystemService::FindFile(std::string_view file_name) {
diff --git a/pw_file/public/pw_file/flat_file_system.h b/pw_file/public/pw_file/flat_file_system.h
index 4efd98d..1035dbd 100644
--- a/pw_file/public/pw_file/flat_file_system.h
+++ b/pw_file/public/pw_file/flat_file_system.h
@@ -107,7 +107,7 @@
// Returns:
// OK - File successfully deleted.
// NOT_FOUND - Could not find
- StatusWithSize Delete(ConstByteSpan request, ByteSpan);
+ void Delete(ConstByteSpan request, rpc::RawUnaryResponder& responder);
private:
// Returns the maximum size of a single encoded Path proto.