aboutsummaryrefslogtreecommitdiff
path: root/pw_kvs/public/pw_kvs/internal/entry.h
diff options
context:
space:
mode:
Diffstat (limited to 'pw_kvs/public/pw_kvs/internal/entry.h')
-rw-r--r--pw_kvs/public/pw_kvs/internal/entry.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/pw_kvs/public/pw_kvs/internal/entry.h b/pw_kvs/public/pw_kvs/internal/entry.h
index 31b0acd30..aa94cbbda 100644
--- a/pw_kvs/public/pw_kvs/internal/entry.h
+++ b/pw_kvs/public/pw_kvs/internal/entry.h
@@ -20,7 +20,6 @@
#include <cstddef>
#include <cstdint>
#include <span>
-#include <string_view>
#include "pw_kvs/alignment.h"
#include "pw_kvs/checksum.h"
@@ -28,8 +27,11 @@
#include "pw_kvs/format.h"
#include "pw_kvs/internal/hash.h"
#include "pw_kvs/internal/key_descriptor.h"
+#include "pw_kvs/key.h"
-namespace pw::kvs::internal {
+namespace pw {
+namespace kvs {
+namespace internal {
// Entry represents a key-value entry in a flash partition.
class Entry {
@@ -63,7 +65,7 @@ class Entry {
static Entry Valid(FlashPartition& partition,
Address address,
const EntryFormat& format,
- std::string_view key,
+ Key key,
std::span<const std::byte> value,
uint32_t transaction_id) {
return Entry(
@@ -74,7 +76,7 @@ class Entry {
static Entry Tombstone(FlashPartition& partition,
Address address,
const EntryFormat& format,
- std::string_view key,
+ Key key,
uint32_t transaction_id) {
return Entry(partition,
address,
@@ -87,9 +89,7 @@ class Entry {
Entry() = default;
- KeyDescriptor descriptor(std::string_view key) const {
- return descriptor(Hash(key));
- }
+ KeyDescriptor descriptor(Key key) const { return descriptor(Hash(key)); }
KeyDescriptor descriptor(uint32_t key_hash) const {
return KeyDescriptor{key_hash,
@@ -97,8 +97,7 @@ class Entry {
deleted() ? EntryState::kDeleted : EntryState::kValid};
}
- StatusWithSize Write(std::string_view key,
- std::span<const std::byte> value) const;
+ StatusWithSize Write(Key key, std::span<const std::byte> value) const;
// Changes the format and transcation ID for this entry. In order to calculate
// the new checksum, the entire entry is read into a small stack-allocated
@@ -125,14 +124,13 @@ class Entry {
Status ValueMatches(std::span<const std::byte> value) const;
- Status VerifyChecksum(std::string_view key,
- std::span<const std::byte> value) const;
+ Status VerifyChecksum(Key key, std::span<const std::byte> value) const;
Status VerifyChecksumInFlash() const;
// Calculates the total size of an entry, including padding.
static size_t size(const FlashPartition& partition,
- std::string_view key,
+ Key key,
std::span<const std::byte> value) {
return AlignUp(sizeof(EntryHeader) + key.size() + value.size(),
std::max(partition.alignment_bytes(), kMinAlignmentBytes));
@@ -178,7 +176,7 @@ class Entry {
Entry(FlashPartition& partition,
Address address,
const EntryFormat& format,
- std::string_view key,
+ Key key,
std::span<const std::byte> value,
uint16_t value_size_bytes,
uint32_t transaction_id);
@@ -202,11 +200,11 @@ class Entry {
}
std::span<const std::byte> checksum_bytes() const {
- return std::as_bytes(std::span(&header_.checksum, 1));
+ return std::as_bytes(std::span<const uint32_t>(&header_.checksum, 1));
}
std::span<const std::byte> CalculateChecksum(
- std::string_view key, std::span<const std::byte> value) const;
+ Key key, std::span<const std::byte> value) const;
Status CalculateChecksumFromFlash();
@@ -223,4 +221,6 @@ class Entry {
EntryHeader header_;
};
-} // namespace pw::kvs::internal
+} // namespace internal
+} // namespace kvs
+} // namespace pw