Files
EchoionCore/include/echoion/core/state/StateSerializer.hpp
T

44 lines
1.0 KiB
C++

#pragma once
#include "StateBlob.hpp"
#include "echoion/core/state/StateVersions.hpp"
#include <Types.hpp>
#include <cstdint>
#include <string>
namespace Echoion::Core
{
class StateSerializer
{
public:
// Current version being used
static constexpr uint32_t CURRENT_VERSION = 1;
// Serialize current state to opaque blob
static Api::StateBlob serialize(const StateV1& state);
// Deserialize blob to current version (handles migration)
static Api::Result<StateV1> deserialize(const Api::StateBlob& blob);
// Check if version is supported
static bool isVersionSupported(uint32_t version);
// Get supported version range
static uint32_t getMinimumSupportedVersion();
static uint32_t getCurrentVersion();
private:
// Extract version from JSON blob
static uint32_t extractVersion(const std::string& jsonStr);
// Helper to get current timestamp
static std::string getCurrentTimestampISO8601();
// Make it accessible to StateMigration
friend class StateMigration;
};
} // namespace Echoion::Core