mirror of
https://github.com/NixOS/nix
synced 2025-06-29 10:31:15 +02:00
Worker proto use proper serialiser for BuildMode
Do this instead of an unchecked cast I redid this to use the serialisation framework (including a unit test), but I am keeping the reference to credit Jade for spotting the issue. Change-Id: Icf6af7935e8f139bef36b40ad475e973aa48855c (adapted from commit 2a7a824d83dc5fb33326b8b89625685f283a743b) Co-Authored-By: Jade Lovelace <lix@jade.fyi>
This commit is contained in:
parent
7de033d63f
commit
eeb89c28b0
6 changed files with 46 additions and 4 deletions
|
@ -14,6 +14,34 @@ namespace nix {
|
|||
|
||||
/* protocol-specific definitions */
|
||||
|
||||
BuildMode WorkerProto::Serialise<BuildMode>::read(const StoreDirConfig & store, WorkerProto::ReadConn conn)
|
||||
{
|
||||
auto temp = readNum<uint8_t>(conn.from);
|
||||
switch (temp) {
|
||||
case bmNormal: return bmNormal;
|
||||
case bmRepair: return bmRepair;
|
||||
case bmCheck: return bmCheck;
|
||||
default: throw Error("Invalid build mode");
|
||||
}
|
||||
}
|
||||
|
||||
void WorkerProto::Serialise<BuildMode>::write(const StoreDirConfig & store, WorkerProto::WriteConn conn, const BuildMode & buildMode)
|
||||
{
|
||||
switch (buildMode) {
|
||||
case bmNormal:
|
||||
conn.to << uint8_t{bmNormal};
|
||||
break;
|
||||
case bmRepair:
|
||||
conn.to << uint8_t{bmRepair};
|
||||
break;
|
||||
case bmCheck:
|
||||
conn.to << uint8_t{bmCheck};
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
};
|
||||
}
|
||||
|
||||
std::optional<TrustedFlag> WorkerProto::Serialise<std::optional<TrustedFlag>>::read(const StoreDirConfig & store, WorkerProto::ReadConn conn)
|
||||
{
|
||||
auto temp = readNum<uint8_t>(conn.from);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue