Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class BinaryTarget z where
- putTargetUnsafe :: Put -> ByteCount -> z
- getTargetOffset :: ByteCount -> Get a -> z -> (Either GetError a, ByteCount)
- getTarget :: BinaryTarget z => Get a -> z -> (Either GetError a, ByteCount)
- putTarget :: BinaryTarget z => Put -> z
- class MutBinaryTarget m z where
- mutPutTargetOffsetUnsafe :: ByteCount -> Put -> ByteCount -> z -> m ByteCount
- mutPutTargetOffset :: MutBinaryTarget m z => ByteCount -> Put -> z -> m ByteCount
- mutPutTarget :: MutBinaryTarget m z => Put -> z -> m ByteCount
- decode :: (Binary a, BinaryTarget z) => z -> (Either GetError a, ByteCount)
- decodeFile :: Binary a => FilePath -> IO (Either GetError a, ByteCount)
- encode :: (Binary a, ByteSized a, BinaryTarget z) => a -> z
- encodeFile :: (Binary a, ByteSized a) => a -> FilePath -> IO ()
- mutEncode :: (Binary a, ByteSized a, MutBinaryTarget m z) => a -> z -> m ByteCount
Documentation
class BinaryTarget z where Source #
Abstracts over the sources we can read from / sinks we can render to.
putTargetUnsafe :: Put -> ByteCount -> z Source #
Put an action to the sink with the given length.
Prefer putTarget
to safely count capacity, or use encode
to use byte size.
getTargetOffset :: ByteCount -> Get a -> z -> (Either GetError a, ByteCount) Source #
Get a value from the source given a starting offset, returning a result and final offset. On error, the offset will indicate where in the source the error occurred.
Instances
BinaryTarget ByteString Source # | |
Defined in Dahdit.Iface putTargetUnsafe :: Put -> ByteCount -> ByteString Source # getTargetOffset :: ByteCount -> Get a -> ByteString -> (Either GetError a, ByteCount) Source # | |
BinaryTarget ShortByteString Source # | |
Defined in Dahdit.Iface putTargetUnsafe :: Put -> ByteCount -> ShortByteString Source # getTargetOffset :: ByteCount -> Get a -> ShortByteString -> (Either GetError a, ByteCount) Source # | |
BinaryTarget ByteArray Source # | |
BinaryTarget (Vector Word8) Source # | |
getTarget :: BinaryTarget z => Get a -> z -> (Either GetError a, ByteCount) Source #
Get a value from the source, returning a result and final offset.
putTarget :: BinaryTarget z => Put -> z Source #
Put an action to the sink with calculated capacity.
class MutBinaryTarget m z where Source #
Instances
(PrimBase m, s ~ PrimState m) => MutBinaryTarget m (MutableByteArray s) Source # | |
Defined in Dahdit.Iface mutPutTargetOffsetUnsafe :: ByteCount -> Put -> ByteCount -> MutableByteArray s -> m ByteCount Source # | |
(PrimBase m, s ~ PrimState m) => MutBinaryTarget m (MVector s Word8) Source # | |
Defined in Dahdit.Iface |
mutPutTargetOffset :: MutBinaryTarget m z => ByteCount -> Put -> z -> m ByteCount Source #
mutPutTarget :: MutBinaryTarget m z => Put -> z -> m ByteCount Source #
decode :: (Binary a, BinaryTarget z) => z -> (Either GetError a, ByteCount) Source #
Decode a value from a source returning a result and consumed byte count.