capnp-0.18.0.0: Cap'n Proto for Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Capnp.Accessors

Description

 
Synopsis

Documentation

readField :: forall k a b mut m. (IsStruct a, ReadCtx m mut) => Field k a b -> Raw a mut -> m (Raw b mut) 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 a 'Const -> 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 b ('Mut s) -> Raw a ('Mut s) -> 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 a ('Mut s) -> m (Raw b ('Mut s)) 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 a mut -> 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 a ('Mut s) -> 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 a 'Const -> 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 a ('Mut s) -> Raw b ('Mut s) -> 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 a ('Mut s) -> m (Raw b ('Mut s)) 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 a ('Mut s) -> 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 a mut -> m (RawWhich a mut) 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 (Which a) mut -> m (RawWhich a mut) Source #

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

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

Get the anonymous union for a struct.

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

Get the struct enclosing an anonymous union.