module Hackage.Security.TUF.Common (
FileLength(..)
, Hash(..)
, KeyThreshold(..)
) where
import Hackage.Security.JSON
newtype FileLength = FileLength { fileLength :: Int54 }
deriving (Eq, Ord, Show)
newtype KeyThreshold = KeyThreshold Int54
deriving (Eq, Ord, Show)
newtype Hash = Hash String
deriving (Eq, Ord, Show)
instance Monad m => ToJSON m KeyThreshold where
toJSON (KeyThreshold i) = toJSON i
instance Monad m => ToJSON m FileLength where
toJSON (FileLength i) = toJSON i
instance Monad m => ToJSON m Hash where
toJSON (Hash str) = toJSON str
instance ReportSchemaErrors m => FromJSON m KeyThreshold where
fromJSON enc = KeyThreshold <$> fromJSON enc
instance ReportSchemaErrors m => FromJSON m FileLength where
fromJSON enc = FileLength <$> fromJSON enc
instance ReportSchemaErrors m => FromJSON m Hash where
fromJSON enc = Hash <$> fromJSON enc