dahdit-0.2.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 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.

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.

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.