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

Capnp.GenHelpers

Description

This module provides various helpers used by generated code; developers are not expected to invoke them directly.

These helpers are used by the low-level api. Capnp.GenHelpers.Pure defines helpers used by high-level api.

Synopsis

Documentation

getWordField :: (ReadCtx m mut, IsWord a) => Struct mut -> Int -> Int -> Word64 -> m a Source #

getWordField struct index offset def fetches a field from the struct's data section. index is the index of the 64-bit word in the data section in which the field resides. offset is the offset in bits from the start of that word to the field. def is the default value for this field.

setWordField :: (RWCtx m s, Bounded a, Integral a, IsWord a, Bits a) => Struct ('Mut s) -> a -> Int -> Int -> Word64 -> m () Source #

setWordField struct value index offset def sets a field in the struct's data section. The meaning of the parameters are as in getWordField, with value being the value to set. The width of the value is inferred from its type.

embedCapPtr :: WriteCtx m s => Message ('Mut s) -> Client -> m (Maybe (Ptr ('Mut s))) Source #

getPtrConst :: FromPtr 'Const a => ByteString -> a Source #

Get a pointer from a ByteString, where the root object is a struct with one pointer, which is the pointer we will retrieve. This is only safe for trusted inputs; it reads the message with a traversal limit of maxBound (and so is suseptable to denial of service attacks), and it calls error if decoding is not successful.

The purpose of this is for defining constants of pointer type from a schema.

getTag :: ReadCtx m mut => Struct mut -> Int -> m Word16 Source #