Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides various helpers used by generated code; developers are not expected to invoke them directly.
These helpers are only used by the high-level api. Capnp.GenHelpers defines helpers used by the low-level api.
Synopsis
- defaultStruct :: (Decerialize a, FromStruct ConstMsg (Cerial ConstMsg a)) => a
- convertValue :: (RWCtx m s, Message m ConstMsg, Cerialize a, ToStruct (MutMsg s) (Cerial (MutMsg s) a), Decerialize b, FromStruct ConstMsg (Cerial ConstMsg b)) => a -> m b
- getRoot :: (FromStruct msg a, ReadCtx m msg) => msg -> m a
- createPure :: (MonadThrow m, Thaw a) => WordCount -> (forall s. PureBuilder s (Mutable s a)) -> m a
- toPurePtrConst :: Decerialize a => Cerial ConstMsg a -> a
- cerializeBasicVec :: (RWCtx m s, MutListElem s (Cerial (MutMsg s) a), Cerialize a) => MutMsg s -> Vector a -> m (List (MutMsg s) (Cerial (MutMsg s) a))
- cerializeCompositeVec :: (RWCtx m s, MutListElem s (Cerial (MutMsg s) a), Marshal a) => MutMsg s -> Vector a -> m (List (MutMsg s) (Cerial (MutMsg s) a))
Documentation
defaultStruct :: (Decerialize a, FromStruct ConstMsg (Cerial ConstMsg a)) => a Source #
A valid implementation for Default
for any type that meets
the given constraints.
convertValue :: (RWCtx m s, Message m ConstMsg, Cerialize a, ToStruct (MutMsg s) (Cerial (MutMsg s) a), Decerialize b, FromStruct ConstMsg (Cerial ConstMsg b)) => a -> m b Source #
getRoot :: (FromStruct msg a, ReadCtx m msg) => msg -> m a Source #
getRoot
returns the root object of a message.
createPure :: (MonadThrow m, Thaw a) => WordCount -> (forall s. PureBuilder s (Mutable s a)) -> m a Source #
creates a capnproto value in pure code according
to createPure
limit mm
, then freezes it without copying. If m
calls throwM
then
createPure
rethrows the exception in the specified monad.
toPurePtrConst :: Decerialize a => Cerial ConstMsg a -> a Source #
convert a low-level value to a high-level one. This is not safe against malicious or invalid input; it is used for declaring top-level constants.
cerializeBasicVec :: (RWCtx m s, MutListElem s (Cerial (MutMsg s) a), Cerialize a) => MutMsg s -> Vector a -> m (List (MutMsg s) (Cerial (MutMsg s) a)) Source #
A valid implementation of cerialize
, which just cerializes the
elements of a list individually and puts them in the list.
Note that while this is *correct* for composite lists, it is inefficient,
since it will separately allocate the elements and then copy them into
the list, doing extra work and leaking space. See cerializeCompositeVec
.
cerializeCompositeVec :: (RWCtx m s, MutListElem s (Cerial (MutMsg s) a), Marshal a) => MutMsg s -> Vector a -> m (List (MutMsg s) (Cerial (MutMsg s) a)) Source #
A valid implementation of cerialize
, which allocates a list of the
correct size and then marshals the elements of a vector into the elements
of the list. This is more efficient for composite types than
cerializeBasicVec
, hence the name.