pw_kvs: Move entry.h to public/pw_kvs/internal

Move entry.h so that the KeyValueStore class can reference it in the
header.

Change-Id: Ib5a7f194db8dd9af1e8f3d8c9c7c25b8409acfe0
diff --git a/pw_kvs/BUILD b/pw_kvs/BUILD
index 6adb71a..64c44b3 100644
--- a/pw_kvs/BUILD
+++ b/pw_kvs/BUILD
@@ -30,10 +30,10 @@
         "entry.cc",
         "flash_memory.cc",
         "key_value_store.cc",
+        "public/pw_kvs/internal/entry.h",
         "public/pw_kvs/internal/hash.h",
         "public/pw_kvs/internal/key_descriptor.h",
         "public/pw_kvs/internal/sector_descriptor.h",
-        "pw_kvs_private/entry.h",
         "pw_kvs_private/macros.h",
     ],
     hdrs = [
diff --git a/pw_kvs/BUILD.gn b/pw_kvs/BUILD.gn
index e626bbb..06bf497 100644
--- a/pw_kvs/BUILD.gn
+++ b/pw_kvs/BUILD.gn
@@ -34,10 +34,10 @@
     "entry.cc",
     "flash_memory.cc",
     "key_value_store.cc",
+    "public/pw_kvs/internal/entry.h",
     "public/pw_kvs/internal/hash.h",
     "public/pw_kvs/internal/key_descriptor.h",
     "public/pw_kvs/internal/sector_descriptor.h",
-    "pw_kvs_private/entry.h",
     "pw_kvs_private/macros.h",
   ]
   sources += public
diff --git a/pw_kvs/entry.cc b/pw_kvs/entry.cc
index ad81b12..c8e6262 100644
--- a/pw_kvs/entry.cc
+++ b/pw_kvs/entry.cc
@@ -12,7 +12,7 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-#include "pw_kvs_private/entry.h"
+#include "pw_kvs/internal/entry.h"
 
 #include <cinttypes>
 #include <cstring>
diff --git a/pw_kvs/entry_test.cc b/pw_kvs/entry_test.cc
index 2c5f7c4..99ef7b1 100644
--- a/pw_kvs/entry_test.cc
+++ b/pw_kvs/entry_test.cc
@@ -12,7 +12,7 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-#include "pw_kvs_private/entry.h"
+#include "pw_kvs/internal/entry.h"
 
 #include <string_view>
 
diff --git a/pw_kvs/key_value_store.cc b/pw_kvs/key_value_store.cc
index ca49b5c..b1b5148 100644
--- a/pw_kvs/key_value_store.cc
+++ b/pw_kvs/key_value_store.cc
@@ -20,19 +20,18 @@
 #include <type_traits>
 
 #define PW_LOG_USE_ULTRA_SHORT_NAMES 1
-#include "pw_kvs_private/entry.h"
+#include "pw_kvs/internal/entry.h"
 #include "pw_kvs_private/macros.h"
 #include "pw_log/log.h"
 
 namespace pw::kvs {
 namespace {
 
-using internal::Entry;
 using std::byte;
 using std::string_view;
 
 constexpr bool InvalidKey(std::string_view key) {
-  return key.empty() || (key.size() > Entry::kMaxKeyLength);
+  return key.empty() || (key.size() > internal::Entry::kMaxKeyLength);
 }
 
 }  // namespace
@@ -732,10 +731,10 @@
   return Status::OK;
 }
 
-Entry KeyValueStore::CreateEntry(Address address,
-                                 std::string_view key,
-                                 span<const byte> value,
-                                 KeyDescriptor::State state) {
+KeyValueStore::Entry KeyValueStore::CreateEntry(Address address,
+                                                std::string_view key,
+                                                span<const byte> value,
+                                                KeyDescriptor::State state) {
   last_transaction_id_ += 1;
 
   if (state == KeyDescriptor::kDeleted) {
diff --git a/pw_kvs/key_value_store_map_test.cc b/pw_kvs/key_value_store_map_test.cc
index 2e04fc0..9b8c13c 100644
--- a/pw_kvs/key_value_store_map_test.cc
+++ b/pw_kvs/key_value_store_map_test.cc
@@ -29,8 +29,8 @@
 #include "gtest/gtest.h"
 #include "pw_kvs/crc16_checksum.h"
 #include "pw_kvs/in_memory_fake_flash.h"
+#include "pw_kvs/internal/entry.h"
 #include "pw_kvs/key_value_store.h"
-#include "pw_kvs_private/entry.h"
 #include "pw_log/log.h"
 #include "pw_span/span.h"
 
diff --git a/pw_kvs/key_value_store_test.cc b/pw_kvs/key_value_store_test.cc
index d47eed4..7922e80 100644
--- a/pw_kvs/key_value_store_test.cc
+++ b/pw_kvs/key_value_store_test.cc
@@ -30,8 +30,8 @@
 #include "pw_checksum/ccitt_crc16.h"
 #include "pw_kvs/crc16_checksum.h"
 #include "pw_kvs/flash_memory.h"
+#include "pw_kvs/internal/entry.h"
 #include "pw_kvs_private/byte_utils.h"
-#include "pw_kvs_private/entry.h"
 #include "pw_kvs_private/macros.h"
 #include "pw_log/log.h"
 #include "pw_span/span.h"
diff --git a/pw_kvs/pw_kvs_private/entry.h b/pw_kvs/public/pw_kvs/internal/entry.h
similarity index 100%
rename from pw_kvs/pw_kvs_private/entry.h
rename to pw_kvs/public/pw_kvs/internal/entry.h
diff --git a/pw_kvs/public/pw_kvs/key_value_store.h b/pw_kvs/public/pw_kvs/key_value_store.h
index c8c8c2e..71f433b 100644
--- a/pw_kvs/public/pw_kvs/key_value_store.h
+++ b/pw_kvs/public/pw_kvs/key_value_store.h
@@ -22,6 +22,7 @@
 #include "pw_containers/vector.h"
 #include "pw_kvs/checksum.h"
 #include "pw_kvs/flash_memory.h"
+#include "pw_kvs/internal/entry.h"
 #include "pw_kvs/internal/key_descriptor.h"
 #include "pw_kvs/internal/sector_descriptor.h"
 #include "pw_span/span.h"
@@ -31,8 +32,6 @@
 namespace pw::kvs {
 namespace internal {
 
-class Entry;
-
 template <typename T, typename = decltype(span(std::declval<T>()))>
 constexpr bool ConvertsToSpan(int) {
   return true;
@@ -171,12 +170,8 @@
 
     const KeyValueStore& kvs_;
 
-    // TODO: Remove the duplicate kMaxKeyLength definition. This should be
-    // provided by the Entry class.
-    static constexpr size_t kMaxKeyLength = 0b111111;
-
     // Buffer large enough for a null-terminated version of any valid key.
-    std::array<char, kMaxKeyLength + 1> key_buffer_;
+    std::array<char, internal::Entry::kMaxKeyLength + 1> key_buffer_;
   };
 
   class iterator {
@@ -234,6 +229,7 @@
 
  protected:
   using Address = FlashPartition::Address;
+  using Entry = internal::Entry;
   using KeyDescriptor = internal::KeyDescriptor;
   using SectorDescriptor = internal::SectorDescriptor;