| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | Haskell2010 | 
Capnp.Convert
Description
This module provides various helper functions to convert between messages, types defined in capnproto schema (called "values" in the rest of this module's documentation), bytestrings (both lazy and strict), and bytestring builders.
Note that most of the functions which decode messages or raw bytes do *not* need to be
 run inside of an instance of MonadLimit; they choose an appropriate limit based on the
 size of the input.
Note that not all conversions exist or necessarily make sense.
Synopsis
- msgToBuilder :: Message 'Const -> Builder
- msgToLBS :: Message 'Const -> ByteString
- msgToBS :: Message 'Const -> ByteString
- bsToMsg :: MonadThrow m => ByteString -> m (Message 'Const)
- lbsToMsg :: MonadThrow m => ByteString -> m (Message 'Const)
- msgToRaw :: forall a m mut. (ReadCtx m mut, IsStruct a) => Message mut -> m (Raw a mut)
- msgToParsed :: forall a m pa. (ReadCtx m 'Const, IsStruct a, Parse a pa) => Message 'Const -> m pa
- bsToRaw :: forall a m. (ReadCtx m 'Const, IsStruct a) => ByteString -> m (Raw a 'Const)
- bsToParsed :: forall a pa m. (ReadCtx m 'Const, IsStruct a, Parse a pa) => ByteString -> m pa
- lbsToRaw :: forall a m. (ReadCtx m 'Const, IsStruct a) => ByteString -> m (Raw a 'Const)
- lbsToParsed :: forall a pa m. (ReadCtx m 'Const, IsStruct a, Parse a pa) => ByteString -> m pa
- parsedToRaw :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m (Raw a ('Mut s))
- parsedToMsg :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m (Message ('Mut s))
- parsedToBuilder :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m Builder
- parsedToBS :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m ByteString
- parsedToLBS :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m ByteString
Documentation
msgToLBS :: Message 'Const -> ByteString Source #
Convert an immutable message to a lazy ByteString.
 To convert a mutable message, freeze it first.
msgToBS :: Message 'Const -> ByteString Source #
Convert an immutable message to a strict ByteString.
 To convert a mutable message, freeze it first.
bsToMsg :: MonadThrow m => ByteString -> m (Message 'Const) Source #
Convert a strict ByteString to a message.
lbsToMsg :: MonadThrow m => ByteString -> m (Message 'Const) Source #
Convert a lazy ByteString to a message.
msgToRaw :: forall a m mut. (ReadCtx m mut, IsStruct a) => Message mut -> m (Raw a mut) Source #
Get the root pointer of a message, wrapped as a Raw.
msgToParsed :: forall a m pa. (ReadCtx m 'Const, IsStruct a, Parse a pa) => Message 'Const -> m pa Source #
Get the root pointer of a message, as a parsed ADT.
bsToRaw :: forall a m. (ReadCtx m 'Const, IsStruct a) => ByteString -> m (Raw a 'Const) Source #
Like msgToRaw, but takes a (strict) bytestring.
bsToParsed :: forall a pa m. (ReadCtx m 'Const, IsStruct a, Parse a pa) => ByteString -> m pa Source #
Like msgToParsed, but takes a (strict) bytestring.
lbsToRaw :: forall a m. (ReadCtx m 'Const, IsStruct a) => ByteString -> m (Raw a 'Const) Source #
Like msgToRaw, but takes a (lazy) bytestring.
lbsToParsed :: forall a pa m. (ReadCtx m 'Const, IsStruct a, Parse a pa) => ByteString -> m pa Source #
Like msgToParsed, but takes a (lazzy) bytestring.
parsedToRaw :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m (Raw a ('Mut s)) Source #
Serialize the parsed form of a struct into its Raw form, and make it the root
 of its message.
parsedToMsg :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m (Message ('Mut s)) Source #
Serialize the parsed form of a struct into a message with that value as its root, returning the message.
parsedToBuilder :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m Builder Source #
Serialize the parsed form of a struct and return it as a Builder
parsedToBS :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m ByteString Source #
Serialize the parsed form of a struct and return it as a strict ByteString
parsedToLBS :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m ByteString Source #
Serialize the parsed form of a struct and return it as a lazy ByteString