Debian Codegraph @

mtxclient/lib/structs/events/encryption.cpp

raw symbols SCIP
1 #include "mtx/events/encryption.hpp"
2
3 #include <nlohmann/json.hpp>
4
5 namespace mtx {
6 namespace events {
7 namespace state {
8
9 void
10 from_json(const nlohmann::json &obj, Encryption &encryption)
11 {
12 encryption.algorithm = obj.at("algorithm").get<std::string>();
13
14 if (obj.contains("rotation_period_ms"))
15 encryption.rotation_period_ms = obj.at("rotation_period_ms").get<uint64_t>();
16 if (obj.contains("rotation_period_msgs"))
17 encryption.rotation_period_msgs = obj.at("rotation_period_msgs").get<uint64_t>();
18 }
19
20 void
21 to_json(nlohmann::json &obj, const Encryption &encryption)
22 {
23 obj["algorithm"] = encryption.algorithm;
24 obj["rotation_period_ms"] = encryption.rotation_period_ms;
25 obj["rotation_period_msgs"] = encryption.rotation_period_msgs;
26 }
27
28 } // namespace state
29 } // namespace events
30 } // namespace mtx