pw_kvs: Implement ValueSize
Change-Id: Ibc57448b704d8f3e57712ed74b60f86c262275c3
diff --git a/pw_kvs/key_value_store.cc b/pw_kvs/key_value_store.cc
index c6ccca8..a245dec 100644
--- a/pw_kvs/key_value_store.cc
+++ b/pw_kvs/key_value_store.cc
@@ -296,6 +296,18 @@
return entry_;
}
+StatusWithSize KeyValueStore::ValueSize(std::string_view key) const {
+ TRY(InvalidOperation(key));
+
+ const KeyDescriptor* key_descriptor;
+ TRY(FindKeyDescriptor(key, &key_descriptor));
+
+ EntryHeader header;
+ TRY(ReadEntryHeader(*key_descriptor, &header));
+
+ return StatusWithSize(header.value_length());
+}
+
Status KeyValueStore::ValidateEntryChecksum(const EntryHeader& header,
string_view key,
const KeyDescriptor& entry) const {
@@ -590,12 +602,12 @@
Status KeyValueStore::VerifyEntry(SectorDescriptor* sector,
KeyDescriptor* key_descriptor) {
+ // TODO: Remove this once checksums are fully implemented.
+ return Status::OK;
+
if (entry_header_format_.checksum == nullptr) {
- // TODO: Remove this once checksums are fully implemented.
return Status::OK;
}
- return Status::UNIMPLEMENTED;
-
// TODO: Implement me!
(void)sector;
(void)key_descriptor;