Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- dataField :: forall b a sz. (ReprFor b ~ 'Data sz, IsWord (UntypedData sz)) => BitCount -> Word16 -> BitCount -> Word64 -> Field 'Slot a b
- ptrField :: forall a b. IsPtr b => Word16 -> Field 'Slot a b
- groupField :: ReprFor b ~ 'Ptr ('Just 'Struct) => Field 'Group a b
- voidField :: ReprFor b ~ 'Data 'Sz0 => Field 'Slot a b
- readVariant :: forall k a b mut m. (IsStruct a, ReadCtx m mut) => Variant k a b -> Raw mut a -> m (Raw mut b)
- data Mutability
- type TypeParam a = (IsPtr a, Parse a (Parsed a))
- newStruct :: forall a m s. (RWCtx m s, TypedStruct a) => () -> Message ('Mut s) -> m (Raw ('Mut s) a)
- parseField :: (IsStruct a, Parse b bp, ReadCtx m 'Const) => Field k a b -> Raw 'Const a -> m bp
- 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 ()
- 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 ()
- initVariant :: forall a b m s. (HasUnion a, RWCtx m s) => Variant 'Group a b -> Raw ('Mut s) a -> m (Raw ('Mut s) b)
- unionWhich :: forall a mut m. (ReadCtx m mut, HasUnion a) => Raw mut (Which a) -> m (RawWhich mut a)
- readField :: forall k a b mut m. (IsStruct a, ReadCtx m mut) => Field k a b -> Raw mut a -> m (Raw mut b)
- structUnion :: HasUnion a => Raw mut a -> Raw mut (Which a)
- unionStruct :: HasUnion a => Raw mut (Which a) -> Raw mut a
- parseEnum :: (ReprFor a ~ 'Data 'Sz16, Enum a, Applicative m) => Raw 'Const a -> m a
- encodeEnum :: forall a m s. (ReprFor a ~ 'Data 'Sz16, Enum a, RWCtx m s) => Message ('Mut s) -> a -> m (Raw ('Mut s) a)
- parseCap :: (IsCap a, ReadCtx m 'Const) => Raw 'Const a -> m (Client a)
- encodeCap :: (IsCap a, RWCtx m s) => Message ('Mut s) -> Client a -> m (Raw ('Mut s) a)
- getPtrConst :: FromPtr 'Const a => ByteString -> a
- module Capnp.Fields
- module Capnp.Repr.Methods
Documentation
dataField :: forall b a sz. (ReprFor b ~ 'Data sz, IsWord (UntypedData sz)) => BitCount -> Word16 -> BitCount -> Word64 -> 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
denotes a value that can be mutated
in the scope of the state token Mut
ss
.
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.
encodeEnum :: forall a m s. (ReprFor a ~ 'Data 'Sz16, Enum a, RWCtx m s) => Message ('Mut s) -> 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.
module Capnp.Fields
module Capnp.Repr.Methods