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

Capnp.GenHelpers.New

Synopsis

Documentation

dataField :: forall b a sz. (ReprFor b ~ 'Data sz, IsWord (UntypedData sz)) => BitCount -> Word16 -> BitCount -> Word64 -> Field 'Slot a b Source #

ptrField :: forall a b. IsPtr b => Word16 -> Field 'Slot a b Source #

readVariant :: forall k a b mut m. (IsStruct a, ReadCtx m mut) => Variant k a b -> Raw mut a -> m (Raw mut b) Source #

Like readField, but accepts a variant. Warning: *DOES NOT CHECK* that the variant is the one that is set. This should only be used by generated code.

data Mutability Source #

Mutability is used as a type parameter (with the DataKinds extension) to indicate the mutability of some values in this library; Const denotes an immutable value, while Mut s denotes a value that can be mutated in the scope of the state token s.

Constructors

Const 
Mut Type 

type TypeParam a = (IsPtr a, Parse a (Parsed a)) Source #

Constraints needed for a to be a capnproto type parameter.

newStruct :: forall a m s. (RWCtx m s, TypedStruct a) => () -> Message ('Mut s) -> m (Raw ('Mut s) a) Source #

parseField :: (IsStruct a, Parse b bp, ReadCtx m 'Const) => Field k a b -> Raw 'Const a -> m bp Source #

parse a struct's field and return its parsed form.

encodeField :: forall a b m s bp. (IsStruct a, Parse b bp, RWCtx m s) => Field 'Slot a b -> bp -> Raw ('Mut s) a -> m () Source #

Marshal a parsed value into a struct's field.

encodeVariant :: forall a b m s bp. (HasUnion a, Parse b bp, RWCtx m s) => Variant 'Slot a b -> bp -> Raw ('Mut s) a -> m () Source #

Set the struct's anonymous union to the given variant, marshalling the supplied value into the message to be its argument. Not applicable for variants whose argument is a group; use initVariant instead.

initVariant :: forall a b m s. (HasUnion a, RWCtx m s) => Variant 'Group a b -> Raw ('Mut s) a -> m (Raw ('Mut s) b) Source #

Set the struct's anonymous union to the given variant, returning the variant's argument, which must be a group (for non-group fields, use setVariant or encodeVariant.

unionWhich :: forall a mut m. (ReadCtx m mut, HasUnion a) => Raw mut (Which a) -> m (RawWhich mut a) Source #

Get a non-opaque view on the anonymous union, which can be used to pattern match on.

readField :: forall k a b mut m. (IsStruct a, ReadCtx m mut) => Field k a b -> Raw mut a -> m (Raw mut b) Source #

Read the value of a field of a struct.

structUnion :: HasUnion a => Raw mut a -> Raw mut (Which a) Source #

Get the anonymous union for a struct.

unionStruct :: HasUnion a => Raw mut (Which a) -> Raw mut a Source #

Get the struct enclosing an anonymous union.

parseEnum :: (ReprFor a ~ 'Data 'Sz16, Enum a, Applicative m) => Raw 'Const a -> m a Source #

encodeEnum :: forall a m s. (ReprFor a ~ 'Data 'Sz16, Enum a, RWCtx m s) => Message ('Mut s) -> a -> m (Raw ('Mut s) a) Source #

parseCap :: (IsCap a, ReadCtx m 'Const) => Raw 'Const a -> m (Client a) Source #

encodeCap :: (IsCap a, RWCtx m s) => Message ('Mut s) -> Client a -> m (Raw ('Mut s) a) 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.