module Vaultaire.Types.WriteResult
(
WriteResult(..),
) where
import Control.Exception (SomeException (..))
import Test.QuickCheck
import Vaultaire.Classes.WireFormat
data WriteResult = InvalidWriteOrigin | OnDisk
deriving (Show, Eq)
instance WireFormat WriteResult where
fromWire bs
| bs == "\x00" = Right OnDisk
| bs == "\x01" = Right InvalidWriteOrigin
| otherwise = Left $ SomeException $ userError "Invalid WriteResult packet"
toWire OnDisk = "\x00"
toWire InvalidWriteOrigin = "\x01"
instance Arbitrary WriteResult where
arbitrary = oneof [ return InvalidWriteOrigin, return OnDisk ]