#include "echoion/core/state/StateSerializer.hpp" #include #include int main() { Echoion::Core::StateV1 state; state.extensionPlugins.push_back({.name = "example", .json = "{\"v\":1}", .version = 3}); auto blob = Echoion::Core::StateSerializer::serialize(state); std::string json{blob.data.begin(), blob.data.end()}; // State written by the removed experimental rooms build must remain safe to // load during a hot reload. Void reflection intentionally ignores unknown // root fields, so the obsolete payload is discarded rather than rejected. json.insert(json.rfind('}'), R"(,"listeningRooms":[{"name":"legacy","subscribers":["uid"]}])"); blob.data.assign(json.begin(), json.end()); const auto restored = Echoion::Core::StateSerializer::deserialize(blob); if (!restored) { std::cerr << "extension state did not deserialize: " << restored.error().message << '\n'; return 1; } if (restored->extensionPlugins.size() != 1 || restored->extensionPlugins.front().name != "example" || restored->extensionPlugins.front().version != 3) { std::cerr << "extension plugin state did not round-trip\n"; return 1; } return 0; }