Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Meta = Meta {}
- data MetaStream a = MetaStream {
- msNullTerminates :: Maybe (SeekRep 'FwdSeek)
- msExpected :: Maybe a
- data Cfg = Cfg {}
- data Error a
- patchBinRep :: forall a s ss rs is i r. (BinRep a, Traversable (FunctorRec rs), r ~ Const Meta, rs ~ RDelete r ss, RElem r ss i, RSubset rs ss is) => Patch s ss a -> Either (Error a) (Patch s rs ByteString)
- class BinRep a where
- toBinRep :: a -> Either String ByteString
- toBinRep' :: BinRep a => a -> Either (Error a) ByteString
- check :: BinRep a => Cfg -> ByteString -> MetaStream a -> Either (Error a) ()
Documentation
data MetaStream a Source #
MetaStream | |
|
Instances
Cfg | |
|
ErrorBadBinRep a String | |
ErrorUnexpectedNonNull ByteString | |
ErrorDidNotMatchExpected ByteString ByteString | |
ErrorBinRepTooLong ByteString Natural |
Instances
patchBinRep :: forall a s ss rs is i r. (BinRep a, Traversable (FunctorRec rs), r ~ Const Meta, rs ~ RDelete r ss, RElem r ss i, RSubset rs ss is) => Patch s ss a -> Either (Error a) (Patch s rs ByteString) Source #
Type has a binary representation for using in patchscripts.
Patchscripts are parsed parameterized over the type to edit. That type needs to become a bytestring for eventual patch application. We're forced into newtypes and typeclasses by Aeson already, so this just enables us to define some important patch generation behaviour in one place. Similarly to Aeson, if you require custom behaviour for existing types (e.g. length-prefixed strings instead of C-style null terminated), define a newtype over it.
Some values may not have valid patch representations, for example if you're
patching a 1-byte length-prefixed string and your string is too long (>255
encoded bytes). Thus, toPatchRep
is failable.
Instances
BinRep String Source # | String is the same but goes the long way round, through Text. |
Defined in StreamPatch.Patch.Binary | |
BinRep ByteString Source # | Bytestrings are copied as-is. |
Defined in StreamPatch.Patch.Binary toBinRep :: ByteString -> Either String ByteString Source # | |
BinRep Text Source # | Text is converted to UTF-8 bytes and null-terminated. |
Defined in StreamPatch.Patch.Binary | |
BinRep HexByteString Source # | |
Defined in BytePatch.HexByteString | |
KnownNat n => BinRep (PascalText n) Source # | |
Defined in StreamPatch.Patch.Binary.PascalText toBinRep :: PascalText n -> Either String ByteString Source # |
check :: BinRep a => Cfg -> ByteString -> MetaStream a -> Either (Error a) () Source #