capnp-0.10.0.0: Cap'n Proto for Haskell
Safe HaskellNone
LanguageHaskell2010

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

Documentation

msgToBuilder :: Message 'Const -> Builder Source #

Convert an immutable message to a bytestring Builder. To convert a mutable message, freeze it first.

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.

msgToValue :: (MonadThrow m, MonadReadMessage mut (LimitT m), MonadReadMessage mut m, FromStruct mut a) => Message mut -> m a Source #

Convert a message to a value.

bsToMsg :: MonadThrow m => ByteString -> m (Message 'Const) Source #

Convert a strict ByteString to a message.

bsToValue :: (MonadThrow m, FromStruct 'Const a) => ByteString -> m a Source #

Convert a strict ByteString to a value.

lbsToMsg :: MonadThrow m => ByteString -> m (Message 'Const) Source #

Convert a lazy ByteString to a message.

lbsToValue :: (MonadThrow m, FromStruct 'Const a) => ByteString -> m a Source #

Convert a lazy ByteString to a value.

valueToBuilder :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m Builder Source #

Convert a value to a Builder.

valueToBS :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m ByteString Source #

Convert a value to a strict ByteString.

valueToLBS :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m ByteString Source #

Convert a value to a lazy ByteString.

valueToMsg :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m (Message ('Mut s)) Source #

Convert a value to a message.