diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2020-01-01 21:27:11 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2020-01-04 21:29:00 +0100 |
commit | b97b503408911130d24d7f07f9247dca8314a316 (patch) | |
tree | 3b4202b42bbe51b2cd5b3720e755a804d7872159 /include | |
parent | ebdbf9a1cd5308bf1c64d8dc912e0ea0e9ac8633 (diff) |
Respond to data requests from network
Diffstat (limited to 'include')
-rw-r--r-- | include/erebos/storage.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/erebos/storage.h b/include/erebos/storage.h index 95a4574..edb0aca 100644 --- a/include/erebos/storage.h +++ b/include/erebos/storage.h @@ -1,6 +1,7 @@ #pragma once #include <array> +#include <cstring> #include <filesystem> #include <memory> #include <optional> @@ -183,7 +184,15 @@ public: Object(Variants content): content(content) {} Object & operator=(const Object &) = delete; + static std::optional<std::tuple<Object, std::vector<uint8_t>::const_iterator>> + decodePrefix(Storage, std::vector<uint8_t>::const_iterator, + std::vector<uint8_t>::const_iterator); + static std::optional<Object> decode(Storage, const std::vector<uint8_t> &); + static std::optional<Object> decode(Storage, + std::vector<uint8_t>::const_iterator, + std::vector<uint8_t>::const_iterator); + static std::vector<Object> decodeMany(Storage, const std::vector<uint8_t> &); std::vector<uint8_t> encode() const; static std::optional<Object> load(const Ref &); @@ -297,3 +306,16 @@ bool Stored<T>::precedes(const Stored<T> & other) const } } + +namespace std +{ + template<> struct hash<erebos::Digest> + { + std::size_t operator()(const erebos::Digest & dgst) const noexcept + { + std::size_t res; + std::memcpy(&res, dgst.arr().data(), sizeof res); + return res; + } + }; +} |