remote: Serializer - add maybeActivity

This commit is contained in:
Richard Marko 2023-11-26 10:38:31 +01:00 committed by sorki
parent f48c7327b7
commit 2462c9ee90
2 changed files with 15 additions and 0 deletions

View File

@ -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

View File

@ -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