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

Capnp.New.Accessors

Description

 
Synopsis

Documentation

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.

getField :: (IsStruct a, ReprFor b ~ 'Data sz, Parse b bp) => Field 'Slot a b -> Raw 'Const a -> bp Source #

Like readField, but:

  • Doesn't need the monadic context; can be used in pure code.
  • Only works for immutable values.
  • Only works for fields in the struct's data section.

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

Set a struct field to a value. Not usable for group fields.

newField :: forall a b m s. (IsStruct a, Allocate b, RWCtx m s) => Field 'Slot a b -> AllocHint b -> Raw ('Mut s) a -> m (Raw ('Mut s) b) Source #

Allocate space for the value of a field, and return it.

hasField :: (ReadCtx m mut, IsStruct a, IsPtr b) => Field 'Slot a b -> Raw mut a -> m Bool Source #

Return whether the specified field is present. Only applicable for pointer fields.

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.

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.

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

Set the struct's anonymous union to the given variant, with the supplied value as 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.

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.

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

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

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.

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.