mirror of
https://github.com/NixOS/nix.git
synced 2025-11-20 01:09:37 +01:00
Convert Realisation JSON logic to standard style
No behavior is changed, just: - Declare a canonical `nlohmnan::json::adl_serializer` - Use `json-utils.hh` to shorten code without getting worse error messages. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
parent
6389f65d63
commit
91593a237f
7 changed files with 73 additions and 61 deletions
|
|
@ -49,13 +49,18 @@ void CommonProto::Serialise<ContentAddress>::write(
|
|||
Realisation CommonProto::Serialise<Realisation>::read(const StoreDirConfig & store, CommonProto::ReadConn conn)
|
||||
{
|
||||
std::string rawInput = readString(conn.from);
|
||||
return Realisation::fromJSON(nlohmann::json::parse(rawInput), "remote-protocol");
|
||||
try {
|
||||
return nlohmann::json::parse(rawInput);
|
||||
} catch (Error & e) {
|
||||
e.addTrace({}, "while parsing a realisation object in the remote protocol");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void CommonProto::Serialise<Realisation>::write(
|
||||
const StoreDirConfig & store, CommonProto::WriteConn conn, const Realisation & realisation)
|
||||
{
|
||||
conn.to << realisation.toJSON().dump();
|
||||
conn.to << static_cast<nlohmann::json>(realisation).dump();
|
||||
}
|
||||
|
||||
DrvOutput CommonProto::Serialise<DrvOutput>::read(const StoreDirConfig & store, CommonProto::ReadConn conn)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue