-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Yet Another Binary Serialisation Library (compatibility shim)
--
-- This package is a shim around cborg, exposing an interface
-- compatible with the previous binary-serialise-cbor.
@package binary-serialise-cbor
@version 0.2.2.0
-- | Tools for reading values in a CBOR-encoded format back into ordinary
-- values.
module Data.Binary.Serialise.CBOR.Read
-- | Run a Decoder incrementally, returning a continuation
-- representing the result of the incremental decode.
deserialiseIncremental :: Decoder s a -> ST s (IDecode s a)
-- | 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 and the number of bytes consumed.
deserialiseFromBytesWithSize :: (forall s. () => Decoder s a) -> ByteString -> Either DeserialiseFailure (ByteString, ByteOffset, a)
-- | An exception type that may be returned (by pure functions) or thrown
-- (by IO actions) that fail to deserialise a given input.
data DeserialiseFailure
DeserialiseFailure :: ByteOffset -> String -> DeserialiseFailure
-- | 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.
data 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.
Partial :: (Maybe ByteString -> ST s (IDecode s a)) -> IDecode s 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.
Done :: !ByteString -> {-# UNPACK #-} !ByteOffset -> a -> IDecode s a
-- | 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.
Fail :: !ByteString -> {-# UNPACK #-} !ByteOffset -> DeserialiseFailure -> IDecode s a
-- | A 0-based offset within the overall byte sequence that makes up the
-- input to the Decoder.
--
-- This is an Int64 since Decoder is incremental and can
-- decode more data than fits in memory at once. This is also compatible
-- with the result type of length.
type ByteOffset = Int64
deserialiseFromBytes :: (forall s. Decoder s a) -> ByteString -> Either DeserialiseFailure a