Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions components/persistent_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,11 @@ A version number reused for a different layout therefore loads with
`layout_mismatch` instead of producing garbage, and a reader without the C++
type (a Python tool) can compute the same fingerprint from a field spec.

alpaca's own `with_version` option is deliberately not used: its hash folds
`sizeof(struct)` in, which differs between a 32-bit ESP32 and a 64-bit host
(a struct of a string, a vector and an integer is 40 bytes on the ESP32, 56 on
macOS and 64 on Linux), so a file written on one would not load on the other.
alpaca's own `with_version` option is not used: the fingerprint above covers
more (enum underlying types, array lengths) and is computable from a field spec
by a reader without the C++ type. (Before alpaca #56 the alpaca hash also folded
`sizeof(struct)` in, which differs between a 32-bit ESP32 and a 64-bit host, so
a file written on one would not have loaded on the other.)

## Errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ namespace espp::persistent_data {
/// @brief Serialization options used for the payload.
/// @details `strict` rejects payloads that are shorter than the type;
/// `fixed_length_encoding` keeps the encoding independent of the
/// values stored. alpaca's own `with_version` is deliberately not used:
/// its hash folds `sizeof(struct)` in, which differs between a 32-bit
/// ESP32 and a 64-bit host, so a file written on one would not load on
/// the other. The header's layout fingerprint (see layout::fingerprint)
/// plays that role portably.
/// values stored. alpaca's own `with_version` is not used: the header's
/// layout fingerprint (see layout::fingerprint) plays that role, and it
/// also encodes enum underlying types and array lengths and can be
/// computed from a field spec by a reader without the C++ type. (Before
/// alpaca #56 the alpaca hash also folded `sizeof(struct)` in, which
/// differs between a 32-bit ESP32 and a 64-bit host.)
inline constexpr alpaca::options SERIALIZATION_OPTIONS =
alpaca::options::fixed_length_encoding | alpaca::options::strict;

Expand Down
2 changes: 1 addition & 1 deletion components/serialization/detail/alpaca
Loading