mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-10-26 21:56:29 +03:00
remote: Serializer - add maybeActivity
This commit is contained in:
parent
f48c7327b7
commit
2462c9ee90
@ -29,6 +29,7 @@ module System.Nix.Store.Remote.Serializer
|
||||
, buildResult
|
||||
-- ** Logger
|
||||
, activityID
|
||||
, maybeActivity
|
||||
, activityResult
|
||||
, field
|
||||
, verbosity
|
||||
@ -197,6 +198,19 @@ buildResult = liftSerialize
|
||||
|
||||
-- ** Logger
|
||||
|
||||
maybeActivity :: NixSerializer r e (Maybe Activity)
|
||||
maybeActivity = Serializer
|
||||
{ getS = getS (int @Int) >>= \case
|
||||
0 -> pure Nothing
|
||||
x -> either fail (pure . Just) $ toEnumCheckBounds (x - 100)
|
||||
, putS = \case
|
||||
Nothing -> putS (int @Int) 0
|
||||
Just act -> putS activity act
|
||||
}
|
||||
where
|
||||
activity :: NixSerializer r e Activity
|
||||
activity = liftSerialize
|
||||
|
||||
activityID :: NixSerializer r e ActivityID
|
||||
activityID = liftSerialize
|
||||
|
||||
|
@ -82,6 +82,7 @@ spec = parallel $ do
|
||||
}
|
||||
describe "Logger" $ do
|
||||
prop "ActivityID" $ roundtripS activityID
|
||||
prop "Maybe Activity" $ roundtripS maybeActivity
|
||||
prop "ActivityResult" $ roundtripS activityResult
|
||||
prop "Field" $ roundtripS field
|
||||
prop "Verbosity" $ roundtripS verbosity
|
||||
|
Loading…
Reference in New Issue
Block a user