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 'Const (Cerial 'Const a)) => a
- convertValue :: (RWCtx m s, MonadReadMessage 'Const m, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a), Decerialize b, FromStruct 'Const (Cerial 'Const b)) => a -> m b
- getRoot :: (FromStruct mut a, ReadCtx m mut) => Message mut -> m a
- createPure :: (MonadThrow m, Thaw a) => WordCount -> (forall s. PureBuilder s (Mutable s a)) -> m a
- toPurePtrConst :: Decerialize a => Cerial 'Const a -> a
- cerializeBasicVec :: (RWCtx m s, MutListElem s (Cerial ('Mut s) a), Cerialize s a) => Message ('Mut s) -> Vector a -> m (List ('Mut s) (Cerial ('Mut s) a))
- cerializeCompositeVec :: (RWCtx m s, MutListElem s (Cerial ('Mut s) a), Marshal s a) => Message ('Mut s) -> Vector a -> m (List ('Mut s) (Cerial ('Mut s) a))
Documentation
defaultStruct :: (Decerialize a, FromStruct 'Const (Cerial 'Const a)) => a Source #
A valid implementation for Default
for any type that meets
the given constraints.
convertValue :: (RWCtx m s, MonadReadMessage 'Const m, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a), Decerialize b, FromStruct 'Const (Cerial 'Const b)) => a -> m b Source #
getRoot :: (FromStruct mut a, ReadCtx m mut) => Message mut -> 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 'Const 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 ('Mut s) a), Cerialize s a) => Message ('Mut s) -> Vector a -> m (List ('Mut s) (Cerial ('Mut 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 ('Mut s) a), Marshal s a) => Message ('Mut s) -> Vector a -> m (List ('Mut s) (Cerial ('Mut 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.