mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +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);
|
auto temp = readNum<uint8_t>(conn.from);
|
||||||
switch (temp) {
|
switch (temp) {
|
||||||
case bmNormal: return bmNormal;
|
case 0: return bmNormal;
|
||||||
case bmRepair: return bmRepair;
|
case 1: return bmRepair;
|
||||||
case bmCheck: return bmCheck;
|
case 2: return bmCheck;
|
||||||
default: throw Error("Invalid build mode");
|
default: throw Error("Invalid build mode");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,13 @@ void WorkerProto::Serialise<BuildMode>::write(const StoreDirConfig & store, Work
|
||||||
{
|
{
|
||||||
switch (buildMode) {
|
switch (buildMode) {
|
||||||
case bmNormal:
|
case bmNormal:
|
||||||
conn.to << uint8_t{bmNormal};
|
conn.to << uint8_t{0};
|
||||||
break;
|
break;
|
||||||
case bmRepair:
|
case bmRepair:
|
||||||
conn.to << uint8_t{bmRepair};
|
conn.to << uint8_t{1};
|
||||||
break;
|
break;
|
||||||
case bmCheck:
|
case bmCheck:
|
||||||
conn.to << uint8_t{bmCheck};
|
conn.to << uint8_t{2};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
Loading…
Reference in a new issue