pw_kvs: Introduce Input interface
- Provide the Input interface, which provides a generic Read function.
- Switch to non-virtual interfaces to allow for potential future
pre/post operations (e.g. error handling, debug logging).
Change-Id: If7e95c3c47a090c7dc0a72426e6224c9ed04b62a
diff --git a/pw_kvs/public/pw_kvs/flash_memory.h b/pw_kvs/public/pw_kvs/flash_memory.h
index 05b823f..b284415 100644
--- a/pw_kvs/public/pw_kvs/flash_memory.h
+++ b/pw_kvs/public/pw_kvs/flash_memory.h
@@ -134,9 +134,22 @@
constexpr Output(FlashPartition& flash, FlashPartition::Address address)
: flash_(flash), address_(address) {}
- StatusWithSize Write(span<const std::byte> data) override;
+ private:
+ StatusWithSize DoWrite(span<const std::byte> data) override;
+
+ FlashPartition& flash_;
+ FlashPartition::Address address_;
+ };
+
+ // Implement Input for the Read method.
+ class Input final : public pw::Input {
+ public:
+ constexpr Input(FlashPartition& flash, FlashPartition::Address address)
+ : flash_(flash), address_(address) {}
private:
+ StatusWithSize DoRead(span<std::byte> data) override;
+
FlashPartition& flash_;
FlashPartition::Address address_;
};