Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 not all conversions exist or necessarily make sense.
Synopsis
- msgToBuilder :: ConstMsg -> Builder
- msgToLBS :: ConstMsg -> ByteString
- msgToBS :: ConstMsg -> ByteString
- msgToValue :: (MonadThrow m, Message (LimitT m) msg, Message m msg, FromStruct msg a) => msg -> m a
- bsToMsg :: MonadThrow m => ByteString -> m ConstMsg
- bsToValue :: (MonadThrow m, FromStruct ConstMsg a) => ByteString -> m a
- lbsToMsg :: MonadThrow m => ByteString -> m ConstMsg
- lbsToValue :: (MonadThrow m, FromStruct ConstMsg a) => ByteString -> m a
- valueToBuilder :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct (MutMsg s) (Cerial (MutMsg s) a)) => a -> m Builder
- valueToBS :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct (MutMsg s) (Cerial (MutMsg s) a)) => a -> m ByteString
- valueToLBS :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct (MutMsg s) (Cerial (MutMsg s) a)) => a -> m ByteString
- valueToMsg :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct (MutMsg s) (Cerial (MutMsg s) a)) => a -> m (MutMsg s)
Documentation
msgToBuilder :: ConstMsg -> Builder Source #
msgToLBS :: ConstMsg -> ByteString Source #
Convert an immutable message to a lazy ByteString
.
To convert a mutable message, freeze
it first.
msgToBS :: ConstMsg -> ByteString Source #
Convert an immutable message to a strict ByteString
.
To convert a mutable message, freeze
it first.
msgToValue :: (MonadThrow m, Message (LimitT m) msg, Message m msg, FromStruct msg a) => msg -> m a Source #
Convert a message to a value.
bsToMsg :: MonadThrow m => ByteString -> m ConstMsg Source #
Convert a strict ByteString
to a message.
bsToValue :: (MonadThrow m, FromStruct ConstMsg a) => ByteString -> m a Source #
Convert a strict ByteString
to a value.
lbsToMsg :: MonadThrow m => ByteString -> m ConstMsg Source #
Convert a lazy ByteString
to a message.
lbsToValue :: (MonadThrow m, FromStruct ConstMsg a) => ByteString -> m a Source #
Convert a lazy ByteString
to a value.
valueToBuilder :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct (MutMsg s) (Cerial (MutMsg s) a)) => a -> m Builder Source #
Convert a value to a Builder
.
valueToBS :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct (MutMsg s) (Cerial (MutMsg s) a)) => a -> m ByteString Source #
Convert a value to a strict ByteString
.
valueToLBS :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct (MutMsg s) (Cerial (MutMsg s) a)) => a -> m ByteString Source #
Convert a value to a lazy ByteString
.