mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Back in enum values for BuildMode
serializer
We don't want to rely on how C assigns numbers for enums in the wire format. Sure, this is totally determined by the ABI, but it obscures the code and makes it harder to safely change the enum definition (should we need to) without accidentally breaking the wire format.
This commit is contained in:
parent
eeb89c28b0
commit
8ebd99c74e
1 changed files with 6 additions and 6 deletions
|
@ -18,9 +18,9 @@ BuildMode WorkerProto::Serialise<BuildMode>::read(const StoreDirConfig & store,
|
|||
{
|
||||
auto temp = readNum<uint8_t>(conn.from);
|
||||
switch (temp) {
|
||||
case bmNormal: return bmNormal;
|
||||
case bmRepair: return bmRepair;
|
||||
case bmCheck: return bmCheck;
|
||||
case 0: return bmNormal;
|
||||
case 1: return bmRepair;
|
||||
case 2: return bmCheck;
|
||||
default: throw Error("Invalid build mode");
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,13 @@ void WorkerProto::Serialise<BuildMode>::write(const StoreDirConfig & store, Work
|
|||
{
|
||||
switch (buildMode) {
|
||||
case bmNormal:
|
||||
conn.to << uint8_t{bmNormal};
|
||||
conn.to << uint8_t{0};
|
||||
break;
|
||||
case bmRepair:
|
||||
conn.to << uint8_t{bmRepair};
|
||||
conn.to << uint8_t{1};
|
||||
break;
|
||||
case bmCheck:
|
||||
conn.to << uint8_t{bmCheck};
|
||||
conn.to << uint8_t{2};
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
|
|
Loading…
Reference in a new issue