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
- 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 ()
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 capacity.
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 (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.
decode :: (Binary a, BinaryTarget z) => z -> (Either GetError a, ByteCount) Source #
Decode a value from a source returning a result and consumed byte count.