Storage entry - represents a single key-value pair in the database.
More...
#include <storage.h>
|
| static bool | deserialize (const uint8_t *data, size_t size, size_t offset, StorageEntry &entry, size_t &bytes_read) |
| | Deserialize one entry from data[offset..], setting bytes_read to the bytes it consumed.
|
| |
| static bool | deserialize (const std::vector< uint8_t > &data, size_t offset, StorageEntry &entry, size_t &bytes_read) |
| | Vector overload of the above; the wire path uses the pointer form to parse straight out of the receive buffer without copying it first.
|
| |
Storage entry - represents a single key-value pair in the database.
Definition at line 107 of file storage.h.
◆ StorageEntry() [1/2]
| librats::StorageEntry::StorageEntry |
( |
| ) |
|
|
inline |
◆ StorageEntry() [2/2]
| librats::StorageEntry::StorageEntry |
( |
const std::string & |
k, |
|
|
StorageValueType |
t, |
|
|
const std::vector< uint8_t > & |
d, |
|
|
uint64_t |
ts, |
|
|
const std::string & |
peer_id |
|
) |
| |
|
inline |
◆ calculate_checksum()
| void librats::StorageEntry::calculate_checksum |
( |
| ) |
|
◆ deserialize() [1/2]
| static bool librats::StorageEntry::deserialize |
( |
const std::vector< uint8_t > & |
data, |
|
|
size_t |
offset, |
|
|
StorageEntry & |
entry, |
|
|
size_t & |
bytes_read |
|
) |
| |
|
static |
Vector overload of the above; the wire path uses the pointer form to parse straight out of the receive buffer without copying it first.
◆ deserialize() [2/2]
| static bool librats::StorageEntry::deserialize |
( |
const uint8_t * |
data, |
|
|
size_t |
size, |
|
|
size_t |
offset, |
|
|
StorageEntry & |
entry, |
|
|
size_t & |
bytes_read |
|
) |
| |
|
static |
Deserialize one entry from data[offset..], setting bytes_read to the bytes it consumed.
Every field is bounds-checked against the entry's own declared length as well as the buffer, so a hostile length can neither read past the buffer nor reach into the entry that follows.
◆ serialize()
| std::vector< uint8_t > librats::StorageEntry::serialize |
( |
| ) |
const |
◆ serialize_into()
| void librats::StorageEntry::serialize_into |
( |
std::vector< uint8_t > & |
out | ) |
const |
Append the serialized entry to out.
What serialize() is built on: a batch appends entry after entry into one buffer instead of allocating a vector per entry only to copy it away again.
◆ serialized_size()
| size_t librats::StorageEntry::serialized_size |
( |
| ) |
const |
Serialized size in bytes, without serializing.
◆ verify_checksum()
| bool librats::StorageEntry::verify_checksum |
( |
| ) |
const |
◆ wins_over()
| bool librats::StorageEntry::wins_over |
( |
const StorageEntry & |
other | ) |
const |
◆ checksum
| uint32_t librats::StorageEntry::checksum |
◆ data
| std::vector<uint8_t> librats::StorageEntry::data |
◆ deleted
| bool librats::StorageEntry::deleted |
◆ key
| std::string librats::StorageEntry::key |
◆ origin_peer_id
| std::string librats::StorageEntry::origin_peer_id |
◆ timestamp_ms
| uint64_t librats::StorageEntry::timestamp_ms |
◆ type
The documentation for this struct was generated from the following file: