mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-11 18:05:56 +03:00
remote: NixSerializer, move maybePath from where clause, expose
This commit is contained in:
parent
936fdf85f5
commit
ec79cfe1ce
@ -33,6 +33,7 @@ module System.Nix.Store.Remote.Serializer
|
||||
, protoVersion
|
||||
-- * StorePath
|
||||
, storePath
|
||||
, maybePath
|
||||
, storePathHashPart
|
||||
, storePathName
|
||||
-- * Metadata
|
||||
@ -409,6 +410,27 @@ storePath = Serializer
|
||||
$ System.Nix.StorePath.storePathToRawFilePath sd p
|
||||
}
|
||||
|
||||
maybePath
|
||||
:: HasStoreDir r
|
||||
=> NixSerializer r SError (Maybe StorePath)
|
||||
maybePath = Serializer
|
||||
{ getS = do
|
||||
getS maybeText >>= \case
|
||||
Nothing -> pure Nothing
|
||||
Just t -> do
|
||||
sd <- Control.Monad.Reader.asks hasStoreDir
|
||||
either
|
||||
(throwError . SError_Path)
|
||||
(pure . pure)
|
||||
$ System.Nix.StorePath.parsePathFromText sd t
|
||||
|
||||
, putS = \case
|
||||
Nothing -> putS maybeText Nothing
|
||||
Just p -> do
|
||||
sd <- Control.Monad.Reader.asks hasStoreDir
|
||||
putS text $ System.Nix.StorePath.storePathToText sd p
|
||||
}
|
||||
|
||||
storePathHashPart :: NixSerializer r SError StorePathHashPart
|
||||
storePathHashPart =
|
||||
mapIsoSerializer
|
||||
@ -485,27 +507,6 @@ pathMetadata = Serializer
|
||||
(fmap System.Nix.ContentAddress.buildContentAddress)
|
||||
maybeText
|
||||
|
||||
maybePath
|
||||
:: HasStoreDir r
|
||||
=> NixSerializer r SError (Maybe StorePath)
|
||||
maybePath = Serializer
|
||||
{ getS = do
|
||||
getS maybeText >>= \case
|
||||
Nothing -> pure Nothing
|
||||
Just t -> do
|
||||
sd <- Control.Monad.Reader.asks hasStoreDir
|
||||
either
|
||||
(throwError . SError_Path)
|
||||
(pure . pure)
|
||||
$ System.Nix.StorePath.parsePathFromText sd t
|
||||
|
||||
, putS = \case
|
||||
Nothing -> putS maybeText Nothing
|
||||
Just p -> do
|
||||
sd <- Control.Monad.Reader.asks hasStoreDir
|
||||
putS text $ System.Nix.StorePath.storePathToText sd p
|
||||
}
|
||||
|
||||
storePathTrust
|
||||
:: NixSerializer r SError StorePathTrust
|
||||
storePathTrust =
|
||||
|
Loading…
Reference in New Issue
Block a user