packages feed

vaultaire-common-2.9.1: lib/Vaultaire/Classes/WireFormat.hs

module Vaultaire.Classes.WireFormat
(
    WireFormat(..),
) where

import Control.Exception (SomeException)
import Data.ByteString (ByteString)

-- | This typeclass encapsulates all wire encoding/decoding, with the
-- possibility of a decode failing.
class WireFormat operation where
    fromWire :: ByteString -> Either SomeException operation
    toWire   :: operation -> ByteString

-- | Default dummy wire format
instance WireFormat () where
    fromWire = error "() has no wire format"
    toWire = error "() has no wire format"