dahdit-0.3.0: Binary parsing and serialization with integrated size
Safe HaskellSafe-Inferred
LanguageHaskell2010

Dahdit.Iface

Synopsis

Documentation

class BinaryTarget z where Source #

Abstracts over the sources we can read from / sinks we can render to.

Methods

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.

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

Instances details
(PrimBase m, s ~ PrimState m) => MutBinaryTarget m (MutableByteArray s) Source # 
Instance details

Defined in Dahdit.Iface

(PrimBase m, s ~ PrimState m) => MutBinaryTarget m (MVector s Word8) Source # 
Instance details

Defined in Dahdit.Iface

decode :: (Binary a, BinaryTarget z) => z -> (Either GetError a, ByteCount) Source #

Decode a value from a source returning a result and consumed byte count.

decodeFile :: Binary a => FilePath -> IO (Either GetError a, ByteCount) Source #

Decode a value from a file.

encode :: (Binary a, ByteSized a, BinaryTarget z) => a -> z Source #

Encode a value to a sink.

encodeFile :: (Binary a, ByteSized a) => a -> FilePath -> IO () Source #

Encode a value to a file.

mutEncode :: (Binary a, ByteSized a, MutBinaryTarget m z) => a -> z -> m ByteCount Source #

Encode a value to a mutable buffer, returning number of bytes filled.