servant-serialization-0.2.1
Safe HaskellSafe-Inferred
LanguageHaskell2010

Servant.API.ContentTypes.SerialiseCBOR

Synopsis

Documentation

data CBOR Source #

Content-type for instances of the Serialise class in the package "serialise". Trailing garbage is ignored.

Instances

Instances details
Accept CBOR Source #

Mime-type for CBOR and additional ones using the word "hackage" and the name of the package "serialise".

Instance details

Defined in Servant.API.ContentTypes.SerialiseCBOR

Serialise a => MimeRender CBOR a Source #
>>> mimeRender (Proxy :: Proxy CBOR) (3.14 :: Float)
"\250@H\245\195"
Instance details

Defined in Servant.API.ContentTypes.SerialiseCBOR

Methods

mimeRender :: Proxy CBOR -> a -> ByteString #

Serialise a => MimeUnrender CBOR a Source #
>>> let bsl = mimeRender (Proxy :: Proxy CBOR) (3.14 :: Float)
>>> mimeUnrender (Proxy :: Proxy CBOR) bsl :: Either String Float
Right 3.14
>>> mimeUnrender (Proxy :: Proxy CBOR) (bsl <> "trailing garbage") :: Either String Float
Right 3.14
>>> mimeUnrender (Proxy :: Proxy CBOR) ("preceding garbage" <> bsl) :: Either String Float
Left "Codec.Serialise.deserialiseOrFail: expected float at byte-offset 0"
Instance details

Defined in Servant.API.ContentTypes.SerialiseCBOR