Commit Graph

8 Commits

Author SHA1 Message Date
Wyatt Hepler
ee6fd76b71 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
2020-03-09 21:32:27 +00:00
Wyatt Hepler
f707880fbe pw_status: StatusWithSize constants
- Provide StatusWithSize constants that can be used similarly to
  Status::Codes. For example, StatusWithSize::DATA_LOSS constructs a
  StatusWithSize with status DATA_LOSS and size 0.
- Remove the default constructor argument for the size. Use the
  constants instead.
- Update uses of StatusWithSize(Status::X) to use StatusWithSize::X.

Change-Id: I901b7bb0bbbb4fde52f6b3acc3047f366b250515
2020-02-25 13:50:41 -08:00
Wyatt Hepler
e541e075d4 pw_kvs: Move reading and writing to Entry class
- Add the FlashPartition and address to the Entry class.
- Move functions for reading or writing the entry header, key, and value
  to the Entry class.

Change-Id: I0af3c140a519c8b050fcef81eca4f3b45560f75c
2020-02-14 16:21:29 -08:00
Wyatt Hepler
50f70779c8 Remove StatusWithSize implicit conversions
- Disallow implicit conversions between Status and StatusWithSize, which
  can be problematic.
- Add TRY_WITH_SIZE to pw_kvs to handle returning StatusWithSize from
  functions.
- Make zero the default size argument for StatusWithSize.
- Expand tests for StatusWithSize.

Change-Id: Ia1c36e5a39402a50138d93e89afbaa5e772adb8a
2020-02-14 17:59:00 +00:00
Wyatt Hepler
1927c2868b pw_kvs: Split out aligned write functionality
- Define the Output interface.
- Create AlignedWriter class, which handles writing aligned and padded
  data to a buffer.
- Define AlignedWriterBuffer, which provides a buffer to an
  AlignedWriter.

Change-Id: I791c5fc2d47617b0866fa779a506cb977905f245
2020-02-12 17:00:09 -08:00
Wyatt Hepler
116d116e4d pw_kvs: Alignment handling adjustments
- Rename multi-span Write to WriteAligned to reflect that the number of
  bytes written may be larger than the input due to padding.
- Make alignment_bytes_ a member of FlashPartition instead of a virtual
  function.
- Enable tests that now pass.

Change-Id: Iad985988ef97607b38fb0c84589cabe752de71a2
2020-02-07 00:36:44 +00:00
Wyatt Hepler
6c24c0638b pw_kvs: Implement Delete; add tests
- Implement Delete function.
- Add new tests and enable a few that pass now.
- Have out-of-bounds flash reads return OUT_OF_RANGE to differentiate
  from INVALID_ARGUMENT.

Change-Id: I5d65ad36913b30f2554bd12eaba26127ae0ec8f2
2020-02-05 18:00:56 -08:00
Wyatt Hepler
4da1fcb4b2 pw_kvs: Initial commit of new KVS design
Builds, but lots more work needed.

Fun fact: this code was written collaboratively in a Google Doc.

Change-Id: I8a89c5d0fdc71ec28cf432350e65d17e24a6f25c
2020-01-31 14:38:37 -08:00