cborg- Concise Binary Object Representation

Copyright(c) Duncan Coutts 2015-2017
LicenseBSD3-style (see LICENSE.txt)
Portabilitynon-portable (GHC extensions)
Safe HaskellNone



Tools for reading values in a CBOR-encoded format back into ordinary values.



deserialiseFromBytes :: (forall s. Decoder s a) -> ByteString -> Either DeserialiseFailure (ByteString, a) Source #

Given a Decoder and some ByteString representing an encoded CBOR value, return Either the decoded CBOR value or an error. In addition to the decoded value return any remaining input content.


deserialiseIncremental :: Decoder s a -> ST s (IDecode s a) Source #

Run a Decoder incrementally, returning a continuation representing the result of the incremental decode.


data DeserialiseFailure Source #

An exception type that may be returned (by pure functions) or thrown (by IO actions) that fail to deserialise a given input.


data IDecode s a Source #

An Incremental decoder, used to represent the result of attempting to run a decoder over a given input, and return a value of type a.


Partial (Maybe ByteString -> ST s (IDecode s a))

The decoder has consumed the available input and needs more to continue. Provide Just if more input is available and Nothing otherwise, and you will get a new IDecode.

Done !ByteString !ByteOffset a

The decoder has successfully finished. Except for the output value you also get any unused input as well as the number of bytes consumed.

Fail !ByteString !ByteOffset DeserialiseFailure

The decoder ran into an error. The decoder either used fail or was not provided enough input. Contains any unconsumed input, the number of bytes consumed, and a DeserialiseFailure exception describing the reason why the failure occurred.

type ByteOffset = Int64 Source #

Simple alias for Int64, used to make types more descriptive.