diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-08-17 14:28:33 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-08-17 14:28:33 -0400 |
commit | f60ac335e4e827fd242ab22539adb49f26e2c319 (patch) | |
tree | 255e16e03210b9ccb6faf72b4afd29b7262f42d9 /Types | |
parent | b474ab87ae45ed77f42eb41f658a55262bd92217 (diff) | |
download | keysafe-f60ac335e4e827fd242ab22539adb49f26e2c319.tar.gz |
add progress bars to restore
also, restore actually works!
Diffstat (limited to 'Types')
-rw-r--r-- | Types/Cost.hs | 13 | ||||
-rw-r--r-- | Types/UI.hs | 4 |
2 files changed, 16 insertions, 1 deletions
diff --git a/Types/Cost.hs b/Types/Cost.hs index 2f181a2..2aa6ee7 100644 --- a/Types/Cost.hs +++ b/Types/Cost.hs @@ -34,11 +34,24 @@ instance Monoid (Cost t) where mapCost :: (Integer -> Integer) -> Cost op -> Cost op mapCost f (CPUCost (Seconds n)) = CPUCost (Seconds (f n)) +showCostMinutes :: Cost op -> String +showCostMinutes (CPUCost (Seconds n)) + | n < 61 = "1 minute" + | otherwise = show (n `div` 60) ++ " minutes" + -- | Operations whose cost can be measured. data DecryptionOp data CreationOp data BruteForceOp +-- | Things that track their creation cost. +class HasCreationCost t where + getCreationCost :: t -> Cost CreationOp + +-- | Things that track their decryption cost. +class HasDecryptionCost t where + getDecryptionCost :: t -> Cost DecryptionOp + -- | Calculation of a cost that depends on some amount of entropy. type CostCalc op t = Entropy t -> Cost op diff --git a/Types/UI.hs b/Types/UI.hs index 0a0c789..7508293 100644 --- a/Types/UI.hs +++ b/Types/UI.hs @@ -3,6 +3,8 @@ - Licensed under the GNU AGPL version 3 or higher. -} +{-# LANGUAGE RankNTypes #-} + module Types.UI where import Types @@ -14,7 +16,7 @@ data UI = UI , promptName :: Title -> Desc -> Name -> (Name -> Maybe Problem) -> IO (Maybe Name) , promptPassword :: Bool -> Title -> Desc -> IO (Maybe Password) , promptKeyId :: Title -> Desc -> [(Name, KeyId)] -> IO (Maybe KeyId) - , withProgress :: Title -> Desc -> ((Percent -> IO ()) -> IO ()) -> IO () + , withProgress :: forall a. Title -> Desc -> ((Percent -> IO ()) -> IO a) -> IO a } type Title = String |