Copyright | (c) Duncan Coutts 2015-2017 |
---|---|
License | BSD3-style (see LICENSE.txt) |
Maintainer | duncan@community.haskell.org |
Stability | experimental |
Portability | non-portable (GHC extensions) |
Safe Haskell | None |
Language | Haskell2010 |
Tools for reading values in a CBOR-encoded format back into ordinary values.
Synopsis
- deserialiseIncremental :: Decoder s a -> ST s (IDecode s a)
- deserialiseFromBytesWithSize :: (forall s. Decoder s a) -> ByteString -> Either DeserialiseFailure (ByteString, ByteOffset, a)
- data DeserialiseFailure = DeserialiseFailure ByteOffset String
- data IDecode s a
- = Partial (Maybe ByteString -> ST s (IDecode s a))
- | Done !ByteString !ByteOffset a
- | Fail !ByteString !ByteOffset DeserialiseFailure
- type ByteOffset = Int64
- deserialiseFromBytes :: (forall s. Decoder s a) -> ByteString -> Either DeserialiseFailure a
Documentation
deserialiseIncremental :: Decoder s a -> ST s (IDecode s a) #
Run a
incrementally, returning a continuation
representing the result of the incremental decode.Decoder
Since: cborg-0.2.0.0
deserialiseFromBytesWithSize :: (forall s. Decoder s a) -> ByteString -> Either DeserialiseFailure (ByteString, ByteOffset, a) #
Given a
and some Decoder
representing
an encoded CBOR value, return ByteString
the decoded CBOR value
or an error. In addition to the decoded value return any remaining input
content and the number of bytes consumed.Either
Since: cborg-0.2.0.0
data DeserialiseFailure #
An exception type that may be returned (by pure functions) or thrown (by IO actions) that fail to deserialise a given input.
Since: cborg-0.2.0.0
Instances
Eq DeserialiseFailure | |
Defined in Codec.CBOR.Read (==) :: DeserialiseFailure -> DeserialiseFailure -> Bool # (/=) :: DeserialiseFailure -> DeserialiseFailure -> Bool # | |
Show DeserialiseFailure | |
Defined in Codec.CBOR.Read showsPrec :: Int -> DeserialiseFailure -> ShowS # show :: DeserialiseFailure -> String # showList :: [DeserialiseFailure] -> ShowS # | |
Exception DeserialiseFailure | |
Defined in Codec.CBOR.Read | |
NFData DeserialiseFailure | |
Defined in Codec.CBOR.Read rnf :: 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
.
Partial (Maybe ByteString -> ST s (IDecode s a)) | The decoder has consumed the available input and needs more
to continue. Provide |
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
|
type ByteOffset = Int64 #
Simple alias for
, used to make types more descriptive.Int64
deserialiseFromBytes :: (forall s. Decoder s a) -> ByteString -> Either DeserialiseFailure a Source #