pw_protobuf: Add TODO for Result<> migration
Currently, Bytes, StringTOXXX and Message all implement Result<> like
API such as ok(), status(). This is mainly due to the IntervalReader
not being compatible with Result<>. The CL adds a few TODO comments
that once pw_bug/363 is resolved, migrate these API to use Result<>
instead.
Bug: 456
Change-Id: I7856088da50acd1a6f9e9bb4aef9b54cfeb95f83
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/61580
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Yecheng Zhao <zyecheng@google.com>
diff --git a/pw_protobuf/public/pw_protobuf/internal/proto_integer_base.h b/pw_protobuf/public/pw_protobuf/internal/proto_integer_base.h
index c50a15d..2e81f3c 100644
--- a/pw_protobuf/public/pw_protobuf/internal/proto_integer_base.h
+++ b/pw_protobuf/public/pw_protobuf/internal/proto_integer_base.h
@@ -28,6 +28,9 @@
public:
constexpr ProtoIntegerBase(Result<Integer> value) : value_(value) {}
constexpr ProtoIntegerBase(Status status) : value_(status) {}
+
+ // TODO(pwbug/363): Migrate this to Result<> once we have StatusOr like
+ // support.
bool ok() { return value_.ok(); }
Status status() { return value_.status(); }
Integer value() { return value_.value(); }
diff --git a/pw_protobuf/public/pw_protobuf/message.h b/pw_protobuf/public/pw_protobuf/message.h
index dedf24c..7ad73e9 100644
--- a/pw_protobuf/public/pw_protobuf/message.h
+++ b/pw_protobuf/public/pw_protobuf/message.h
@@ -97,6 +97,9 @@
Bytes(Status status) : reader_(status) {}
Bytes(stream::IntervalReader reader) : reader_(reader) {}
const stream::IntervalReader& GetBytesReader() { return reader_; }
+
+ // TODO(pwbug/363): Migrate this to Result<> once we have StatusOr like
+ // support.
bool ok() { return reader_.ok(); }
Status status() { return reader_.status(); }
@@ -344,8 +347,11 @@
// message.
Bytes ToBytes() { return Bytes(reader_.Reset()); }
+ // TODO(pwbug/363): Migrate this to Result<> once we have StatusOr like
+ // support.
bool ok() { return reader_.ok(); }
Status status() { return reader_.status(); }
+
iterator begin();
iterator end();
@@ -484,8 +490,11 @@
RepeatedFieldParser(Message& message, uint32_t field_number)
: message_(message), field_number_(field_number) {}
+ // TODO(pwbug/363): Migrate this to Result<> once we have StatusOr like
+ // support.
bool ok() { return message_.ok(); }
Status status() { return message_.status(); }
+
iterator begin() { return iterator(*this, message_.begin()); }
iterator end() { return iterator(*this, message_.end()); }
diff --git a/pw_stream/public/pw_stream/interval_reader.h b/pw_stream/public/pw_stream/interval_reader.h
index c1ef2b0..43b020a 100644
--- a/pw_stream/public/pw_stream/interval_reader.h
+++ b/pw_stream/public/pw_stream/interval_reader.h
@@ -34,7 +34,8 @@
//
// The reader additionally embedds a `Status` to indicate whether itself
// is valid. This is a workaround for Reader not being compatibile with
-// Result<>.
+// Result<>. TODO(pwbug/363): Migrate this to Result<> once we have StatusOr
+// like support.
class IntervalReader : public SeekableReader {
public:
constexpr IntervalReader() : status_(Status::Unavailable()) {}