-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remote: generalize error in sockPutS, sockGetS, add Types.WorkerMagic…
…, workerMagic serializer, HandshakeSError
- Loading branch information
Showing
7 changed files
with
87 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
hnix-store-remote/src/System/Nix/Store/Remote/Types/WorkerMagic.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module System.Nix.Store.Remote.Types.WorkerMagic | ||
( WorkerMagic(..) | ||
, workerMagicToWord64 | ||
, word64ToWorkerMagic | ||
) where | ||
|
||
import Data.Word (Word64) | ||
import GHC.Generics (Generic) | ||
|
||
-- | WorkerMagic | ||
-- | ||
-- Magic numbers exchange during handshake | ||
data WorkerMagic | ||
= WorkerMagic_One | ||
| WorkerMagic_Two | ||
deriving (Eq, Generic, Ord, Show) | ||
|
||
workerMagicToWord64 :: WorkerMagic -> Word64 | ||
workerMagicToWord64 = \case | ||
WorkerMagic_One -> 0x6e697863 | ||
WorkerMagic_Two -> 0x6478696f | ||
|
||
word64ToWorkerMagic :: Word64 -> Either String WorkerMagic | ||
word64ToWorkerMagic = \case | ||
0x6e697863 -> Right WorkerMagic_One | ||
0x6478696f -> Right WorkerMagic_Two | ||
x -> Left $ "Invalid WorkerMagic: " ++ show x |