Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data LimitT m a
- class Monad m => MonadLimit m where
- runLimitT :: MonadThrow m => WordCount -> LimitT m a -> m (a, WordCount)
- evalLimitT :: MonadThrow m => WordCount -> LimitT m a -> m a
- execLimitT :: MonadThrow m => WordCount -> LimitT m a -> m WordCount
- defaultLimit :: WordCount
- hPutMsg :: Handle -> Message 'Const -> IO ()
- putMsg :: Message 'Const -> IO ()
- hGetMsg :: Handle -> WordCount -> IO (Message 'Const)
- getMsg :: WordCount -> IO (Message 'Const)
- class IsWord a where
- ListStruct :: ParsedList (Parsed AnyStruct) -> Parsed AnyList
- List64 :: ParsedList Word64 -> Parsed AnyList
- List32 :: ParsedList Word32 -> Parsed AnyList
- List16 :: ParsedList Word16 -> Parsed AnyList
- List8 :: ParsedList Word8 -> Parsed AnyList
- List1 :: ParsedList Bool -> Parsed AnyList
- List0 :: ParsedList () -> Parsed AnyList
- PtrStruct :: Parsed AnyStruct -> Parsed AnyPointer
- PtrList :: Parsed AnyList -> Parsed AnyPointer
- PtrCap :: Client -> Parsed AnyPointer
- Struct :: Vector Word64 -> Vector (Maybe (Parsed AnyPointer)) -> Parsed AnyStruct
- ListPtr :: ParsedList (Maybe (Parsed AnyPointer)) -> Parsed AnyList
- structData :: Parsed AnyStruct -> Vector Word64
- structPtrs :: Parsed AnyStruct -> Vector (Maybe (Parsed AnyPointer))
- class (Parse a ap, Allocate (List a)) => EstimateListAlloc a ap where
- estimateListAlloc :: Vector ap -> AllocHint (List a)
- class (IsCap p, IsCap c) => Super p c
- type MarshalElement a ap = (Parse a ap, EstimateListAlloc a ap, Element (ReprFor a), MarshalElementByRepr (ListReprFor (ReprFor a)), MarshalElementReprConstraints (ListReprFor (ReprFor a)) a ap)
- class (IsStruct a, Allocate a, HasTypeId a, AllocHint a ~ ()) => TypedStruct a where
- class HasTypeId a where
- class Parse t p => Marshal t p where
- marshalInto :: RWCtx m s => Raw ('Mut s) t -> p -> m ()
- class AllocateList a where
- type ListAllocHint a
- newList :: RWCtx m s => ListAllocHint a -> Message ('Mut s) -> m (Raw ('Mut s) (List a))
- class Allocate a where
- class (Parse t p, Allocate t) => EstimateAlloc t p where
- estimateAlloc :: p -> AllocHint t
- class Parse t p | t -> p, p -> t where
- newFromRepr :: forall a r m s. (Allocate r, 'Ptr ('Just r) ~ ReprFor a, RWCtx m s) => AllocHint r -> Message ('Mut s) -> m (Raw ('Mut s) a)
- newTypedStruct :: forall a m s. (TypedStruct a, RWCtx m s) => Message ('Mut s) -> m (Raw ('Mut s) a)
- newTypedStructList :: forall a m s. (TypedStruct a, RWCtx m s) => Int -> Message ('Mut s) -> m (Raw ('Mut s) (List a))
- structSizes :: forall a. TypedStruct a => (Word16, Word16)
- newRoot :: forall a m s. (RWCtx m s, IsStruct a, Allocate a) => AllocHint a -> Message ('Mut s) -> m (Raw ('Mut s) a)
- type ParsedList a = Vector a
- data Capability
- data AnyStruct
- data AnyList
- data AnyPointer
- data Data
- data Text
- readField :: forall k a b mut m. (IsStruct a, ReadCtx m mut) => Field k a b -> Raw mut a -> m (Raw mut b)
- hasField :: (ReadCtx m mut, IsStruct a, IsPtr b) => Field 'Slot a b -> Raw mut a -> m Bool
- getField :: (IsStruct a, ReprFor b ~ 'Data sz, Parse b bp) => Field 'Slot a b -> Raw 'Const a -> bp
- setField :: forall a b m s. (IsStruct a, RWCtx m s) => Field 'Slot a b -> Raw ('Mut s) b -> Raw ('Mut s) a -> m ()
- 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)
- 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 ()
- parseField :: (IsStruct a, Parse b bp, ReadCtx m 'Const) => Field k a b -> Raw 'Const a -> m bp
- setVariant :: forall a b m s. (HasUnion a, RWCtx m s) => Variant 'Slot a b -> Raw ('Mut s) a -> Raw ('Mut s) b -> 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)
- structUnion :: HasUnion a => Raw mut a -> Raw mut (Which a)
- unionStruct :: HasUnion a => Raw mut (Which a) -> Raw mut a
- structWhich :: forall a mut m. (ReadCtx m mut, HasUnion a) => Raw mut a -> m (RawWhich mut a)
- unionWhich :: forall a mut m. (ReadCtx m mut, HasUnion a) => Raw mut (Which a) -> m (RawWhich mut a)
- msgToBuilder :: Message 'Const -> Builder
- msgToLBS :: Message 'Const -> ByteString
- msgToBS :: Message 'Const -> ByteString
- msgToValue :: (MonadThrow m, MonadReadMessage mut (LimitT m), MonadReadMessage mut m, FromStruct mut a) => Message mut -> m a
- bsToMsg :: MonadThrow m => ByteString -> m (Message 'Const)
- bsToValue :: (MonadThrow m, FromStruct 'Const a) => ByteString -> m a
- lbsToMsg :: MonadThrow m => ByteString -> m (Message 'Const)
- lbsToValue :: (MonadThrow m, FromStruct 'Const a) => ByteString -> m a
- valueToBuilder :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m Builder
- valueToBS :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m ByteString
- valueToLBS :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m ByteString
- valueToMsg :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m (Message ('Mut s))
- msgToRaw :: forall a m mut. (ReadCtx m mut, IsStruct a) => Message mut -> m (Raw mut a)
- msgToParsed :: forall a m pa. (ReadCtx m 'Const, IsStruct a, Parse a pa) => Message 'Const -> m pa
- bsToRaw :: (ReadCtx m 'Const, IsStruct a) => ByteString -> m (Raw 'Const a)
- bsToParsed :: (ReadCtx m 'Const, IsStruct a, Parse a pa) => ByteString -> m pa
- lbsToRaw :: (ReadCtx m 'Const, IsStruct a) => ByteString -> m (Raw 'Const a)
- lbsToParsed :: (ReadCtx m 'Const, IsStruct a, Parse a pa) => ByteString -> m pa
- parsedToRaw :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m (Raw ('Mut s) a)
- parsedToMsg :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m (Message ('Mut s))
- parsedToBuilder :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m Builder
- parsedToLBS :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m ByteString
- parsedToBS :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m ByteString
- hGetValue :: FromStruct 'Const a => Handle -> WordCount -> IO a
- getValue :: FromStruct 'Const a => WordCount -> IO a
- sGetValue :: FromStruct 'Const a => Socket -> WordCount -> IO a
- sGetMsg :: Socket -> WordCount -> IO (Message 'Const)
- hPutValue :: (Cerialize RealWorld a, ToStruct ('Mut RealWorld) (Cerial ('Mut RealWorld) a)) => Handle -> a -> IO ()
- putValue :: (Cerialize RealWorld a, ToStruct ('Mut RealWorld) (Cerial ('Mut RealWorld) a)) => a -> IO ()
- sPutMsg :: Socket -> Message 'Const -> IO ()
- sPutValue :: (Cerialize RealWorld a, ToStruct ('Mut RealWorld) (Cerial ('Mut RealWorld) a)) => Socket -> a -> IO ()
- hGetParsed :: forall a pa. (IsStruct a, Parse a pa) => Handle -> WordCount -> IO pa
- sGetParsed :: forall a pa. (IsStruct a, Parse a pa) => Socket -> WordCount -> IO pa
- getParsed :: (IsStruct a, Parse a pa) => WordCount -> IO pa
- hPutParsed :: (IsStruct a, Parse a pa) => Handle -> pa -> IO ()
- putParsed :: (IsStruct a, Parse a pa) => pa -> IO ()
- sPutParsed :: (IsStruct a, Parse a pa) => Socket -> pa -> IO ()
- hGetRaw :: IsStruct a => Handle -> WordCount -> IO (Raw 'Const a)
- getRaw :: IsStruct a => WordCount -> IO (Raw 'Const a)
- sGetRaw :: IsStruct a => Socket -> WordCount -> IO (Raw 'Const a)
- class AsClient f where
- newtype Client a = Client Client
- newtype Pipeline a = Pipeline Pipeline
- class (IsCap c, IsStruct p, IsStruct r) => HasMethod (name :: Symbol) c p r | name c -> p r where
- methodByLabel :: Method c p r
- data Method c p r = Method {
- interfaceId :: !Word64
- methodId :: !Word16
- upcast :: (AsClient f, Coercible (f p) (f c), Super p c) => f c -> f p
- callB :: (AsClient f, IsCap c, IsStruct p, MonadSTM m) => Method c p r -> (forall s. PureBuilder s (Raw ('Mut s) p)) -> f c -> m (Pipeline r)
- callR :: (AsClient f, IsCap c, IsStruct p, MonadSTM m) => Method c p r -> Raw 'Const p -> f c -> m (Pipeline r)
- callP :: forall c p r f m pp. (AsClient f, IsCap c, IsStruct p, Parse p pp, MonadSTM m, MonadThrow m) => Method c p r -> pp -> f c -> m (Pipeline r)
- pipe :: (IsStruct a, ReprFor b ~ 'Ptr pr) => Field k a b -> Pipeline a -> Pipeline b
- pipelineClient :: (IsCap a, MonadSTM m) => Pipeline a -> m (Client a)
- waitPipeline :: forall a m pr. ('Ptr pr ~ ReprFor a, IsPtrRepr pr, MonadSTM m) => Pipeline a -> m (Raw 'Const a)
- type TypeParam a = (IsPtr a, Parse a (Parsed a))
- type Parsed a = ParsedByRepr (ReprFor a) a
- newtype Raw (mut :: Mutability) (a :: Type) = Raw {}
- data List a
- index :: forall a m mut. (ReadCtx m mut, Element (ReprFor a)) => Int -> Raw mut (List a) -> m (Raw mut a)
- setIndex :: forall a m s. (RWCtx m s, Element (ReprFor a)) => Raw ('Mut s) a -> Int -> Raw ('Mut s) (List a) -> m ()
- length :: Raw mut (List a) -> Int
- data Field (k :: FieldKind) a b
- data FieldKind
- class IsStruct a => HasField (name :: Symbol) k a b | a name -> k b where
- fieldByLabel :: Field k a b
- class IsStruct a => HasUnion a where
- data Which a
- data RawWhich (mut :: Mutability) a
- unionField :: Field 'Slot a Word16
- internalWhich :: ReadCtx m mut => Word16 -> Raw mut a -> m (RawWhich mut a)
- class HasUnion a => HasVariant (name :: Symbol) k a b | a name -> k b where
- variantByLabel :: Variant k a b
- data Message (mut :: Mutability)
- data Segment (mut :: Mutability)
- data Mutability
- class Monad m => MonadReadMessage mut m where
- numSegs :: Message mut -> m Int
- numWords :: Segment mut -> m WordCount
- numCaps :: Message mut -> m Int
- internalGetSeg :: Message mut -> Int -> m (Segment mut)
- internalGetCap :: Message mut -> Int -> m Client
- slice :: WordCount -> WordCount -> Segment mut -> m (Segment mut)
- read :: Segment mut -> WordCount -> m Word64
- newMessage :: WriteCtx m s => Maybe WordCount -> m (Message ('Mut s))
- fromByteString :: ByteString -> Segment 'Const
- toByteString :: Segment 'Const -> ByteString
- data PureBuilder s a
- createPure :: (MonadThrow m, Thaw a) => WordCount -> (forall s. PureBuilder s (Mutable s a)) -> m a
- canonicalize :: (RWCtx m s, MonadReadMessage mutIn m) => Struct mutIn -> m (Message ('Mut s), Segment ('Mut s))
- type MethodHandler p r = Raw 'Const p -> Fulfiller (Raw 'Const r) -> IO ()
- class SomeServer a where
- class (IsCap i, HasTypeId i) => Export i where
- type Server i :: * -> Constraint
- export :: forall i s m. (MonadSTM m, Export i, Server i s, SomeServer s) => Supervisor -> s -> m (Client i)
- handleParsed :: (Parse p pp, IsStruct p, Parse r rr, IsStruct r) => (pp -> IO rr) -> MethodHandler p r
- handleRaw :: (IsStruct p, IsStruct r) => (Raw 'Const p -> IO (Raw 'Const r)) -> MethodHandler p r
- methodUnimplemented :: MethodHandler p r
- def :: Default a => a
Documentation
Monad transformer implementing MonadLimit
. The underlying monad
must implement MonadThrow
. invoice
calls
when the limit is exhausted.throwM
TraversalLimitError
Instances
MonadTrans LimitT Source # | |
Defined in Capnp.TraversalLimit | |
MonadState s m => MonadState s (LimitT m) Source # | |
Monad m => Monad (LimitT m) Source # | |
Functor m => Functor (LimitT m) Source # | |
MonadFail m => MonadFail (LimitT m) Source # | |
Defined in Capnp.TraversalLimit | |
Monad m => Applicative (LimitT m) Source # | |
MonadIO m => MonadIO (LimitT m) Source # | |
Defined in Capnp.TraversalLimit | |
MonadThrow m => MonadThrow (LimitT m) Source # | |
Defined in Capnp.TraversalLimit | |
MonadCatch m => MonadCatch (LimitT m) Source # | |
(PrimMonad m, s ~ PrimState m) => PrimMonad (LimitT m) Source # | |
MonadThrow m => MonadLimit (LimitT m) Source # | |
type PrimState (LimitT m) Source # | |
Defined in Capnp.TraversalLimit |
class Monad m => MonadLimit m where Source #
mtl-style type class to track the traversal limit. This is used by other parts of the library which actually do the reading.
invoice :: WordCount -> m () Source #
deducts invoice
nn
from the traversal limit, signaling
an error if the limit is exhausted.
Instances
MonadThrow m => MonadLimit (LimitT m) Source # | |
MonadLimit (PureBuilder s) Source # | |
Defined in Internal.BuildPure invoice :: WordCount -> PureBuilder s () Source # | |
MonadLimit m => MonadLimit (ReaderT r m) Source # | |
(Monoid w, MonadLimit m) => MonadLimit (WriterT w m) Source # | |
MonadLimit m => MonadLimit (StateT s m) Source # | |
MonadLimit m => MonadLimit (StateT s m) Source # | |
(Monoid w, MonadLimit m) => MonadLimit (RWST r w s m) Source # | |
runLimitT :: MonadThrow m => WordCount -> LimitT m a -> m (a, WordCount) Source #
Run a LimitT
, returning the value from the computation and the remaining
traversal limit.
evalLimitT :: MonadThrow m => WordCount -> LimitT m a -> m a Source #
Run a LimitT
, returning the value from the computation.
execLimitT :: MonadThrow m => WordCount -> LimitT m a -> m WordCount Source #
Run a LimitT
, returning the remaining traversal limit.
defaultLimit :: WordCount Source #
A sensible default traversal limit. Currently 64 MiB.
hGetMsg :: Handle -> WordCount -> IO (Message 'Const) Source #
reads a message from hGetMsg
handle limithandle
that is at most
limit
64-bit words in length.
Types that can be converted to and from a 64-bit word.
Anything that goes in the data section of a struct will have an instance of this.
fromWord :: Word64 -> a Source #
Convert from a 64-bit words Truncates the word if the type has less than 64 bits.
toWord :: a -> Word64 Source #
Convert to a 64-bit word.
Instances
IsWord Bool Source # | |
IsWord Double Source # | |
IsWord Float Source # | |
IsWord Int8 Source # | |
IsWord Int16 Source # | |
IsWord Int32 Source # | |
IsWord Int64 Source # | |
IsWord Word8 Source # | |
IsWord Word16 Source # | |
IsWord Word32 Source # | |
IsWord Word64 Source # | |
IsWord Word1 Source # | |
IsWord ElementSize Source # | |
Defined in Capnp.Gen.Capnp.Schema fromWord :: Word64 -> ElementSize Source # toWord :: ElementSize -> Word64 Source # | |
IsWord Side Source # | |
IsWord Exception'Type Source # | |
Defined in Capnp.Gen.Capnp.Rpc fromWord :: Word64 -> Exception'Type Source # toWord :: Exception'Type -> Word64 Source # | |
IsWord ElementSize Source # | |
Defined in Capnp.Gen.Capnp.Schema.New fromWord :: Word64 -> ElementSize Source # toWord :: ElementSize -> Word64 Source # | |
IsWord Side Source # | |
IsWord Exception'Type Source # | |
Defined in Capnp.Gen.Capnp.Rpc.New fromWord :: Word64 -> Exception'Type Source # toWord :: Exception'Type -> Word64 Source # |
ListStruct :: ParsedList (Parsed AnyStruct) -> Parsed AnyList Source #
ListPtr :: ParsedList (Maybe (Parsed AnyPointer)) -> Parsed AnyList Source #
structPtrs :: Parsed AnyStruct -> Vector (Maybe (Parsed AnyPointer)) Source #
class (Parse a ap, Allocate (List a)) => EstimateListAlloc a ap where Source #
Nothing
Instances
class (IsCap p, IsCap c) => Super p c Source #
An instance
indicates that the interface Super
p cc
extends
the interface p
.
type MarshalElement a ap = (Parse a ap, EstimateListAlloc a ap, Element (ReprFor a), MarshalElementByRepr (ListReprFor (ReprFor a)), MarshalElementReprConstraints (ListReprFor (ReprFor a)) a ap) Source #
Type alias capturing the constraints on a type needed by
marshalElement
class (IsStruct a, Allocate a, HasTypeId a, AllocHint a ~ ()) => TypedStruct a where Source #
Operations on typed structs.
Instances
class HasTypeId a where Source #
Types which have a numeric type-id defined in a capnp schema.
The node id for this type. You will generally want to use the
TypeApplications
extension to specify the type.
Instances
class Parse t p => Marshal t p where Source #
An instance of marshal allows a parsed value to be inserted into pre-allocated space in a message.
marshalInto :: RWCtx m s => Raw ('Mut s) t -> p -> m () Source #
Marshal a value into the pre-allocated object inside the message.
Note that caller must arrange for the object to be of the correct size. This is is not necessarily guaranteed; for example, list types must coordinate the length of the list.
Instances
class AllocateList a where Source #
Like Allocate
, but for allocating *lists* of a
.
Nothing
type ListAllocHint a Source #
Extra information needed to allocate a list of a
s.
Instances
class Allocate a where Source #
Types which may be allocated directly inside a message.
Nothing
Extra information needed to allocate a value of this type, e.g. the length for a list. May be () if no extra info is needed.
new :: RWCtx m s => AllocHint a -> Message ('Mut s) -> m (Raw ('Mut s) a) Source #
allocates a new value of type new
hint msga
inside msg
.
Instances
class (Parse t p, Allocate t) => EstimateAlloc t p where Source #
Types where the necessary allocation is inferrable from the parsed form.
...this is most types.
Nothing
estimateAlloc :: p -> AllocHint t Source #
Determine the appropriate hint needed to allocate space for the serialied form of the value.
default estimateAlloc :: AllocHint t ~ () => p -> AllocHint t Source #
Instances
class Parse t p | t -> p, p -> t where Source #
Capnp types that can be parsed into a more "natural" Haskell form.
t
is the capnproto type.p
is the type of the parsed value.
parse :: ReadCtx m 'Const => Raw 'Const t -> m p Source #
Parse a value from a constant message
encode :: RWCtx m s => Message ('Mut s) -> p -> m (Raw ('Mut s) t) Source #
Encode a value into Raw
form, using the message as storage.
Instances
newFromRepr :: forall a r m s. (Allocate r, 'Ptr ('Just r) ~ ReprFor a, RWCtx m s) => AllocHint r -> Message ('Mut s) -> m (Raw ('Mut s) a) Source #
newTypedStruct :: forall a m s. (TypedStruct a, RWCtx m s) => Message ('Mut s) -> m (Raw ('Mut s) a) Source #
newTypedStructList :: forall a m s. (TypedStruct a, RWCtx m s) => Int -> Message ('Mut s) -> m (Raw ('Mut s) (List a)) Source #
Like newTypedStruct
, but for lists.
structSizes :: forall a. TypedStruct a => (Word16, Word16) Source #
Get the maximum word and pointer counts needed for a struct type's fields.
newRoot :: forall a m s. (RWCtx m s, IsStruct a, Allocate a) => AllocHint a -> Message ('Mut s) -> m (Raw ('Mut s) a) Source #
Like new
, but also sets the value as the root of the message.
type ParsedList a = Vector a Source #
data Capability Source #
A Cap'n Proto capability with unknown interfaces.
Instances
Parse Capability Client Source # | |
type ReprFor Capability Source # | |
Defined in Capnp.New.Basics |
A Cap'n Proto struct of unknown type.
Instances
AllocateList AnyStruct Source # | |
Allocate AnyStruct Source # | |
EstimateListAlloc AnyStruct (Parsed AnyStruct) Source # | |
Defined in Capnp.New.Basics | |
Marshal AnyStruct (Parsed AnyStruct) Source # | |
Defined in Capnp.New.Basics | |
EstimateAlloc AnyStruct (Parsed AnyStruct) Source # | |
Defined in Capnp.New.Basics | |
Parse AnyStruct (Parsed AnyStruct) Source # | |
Eq (Parsed AnyStruct) Source # | |
Show (Parsed AnyStruct) Source # | |
type ReprFor AnyStruct Source # | |
data Parsed AnyStruct Source # | |
Defined in Capnp.New.Basics data Parsed AnyStruct = Struct {
| |
type ListAllocHint AnyStruct Source # | |
Defined in Capnp.New.Basics | |
type AllocHint AnyStruct Source # | |
Defined in Capnp.New.Basics |
A Cap'n Proto List
with unknown element type.
Instances
Parse AnyList (Parsed AnyList) Source # | |
Eq (Parsed AnyList) Source # | |
Show (Parsed AnyList) Source # | |
type ReprFor AnyList Source # | |
data Parsed AnyList Source # | |
Defined in Capnp.New.Basics data Parsed AnyList
|
data AnyPointer Source #
A Cap'n Proto AnyPointer
, i.e. an arbitrary pointer with unknown schema.
Instances
The Cap'n Proto Data
type.
Instances
AllocateList Data Source # | |
Allocate Data Source # | |
EstimateListAlloc Data ByteString Source # | |
Defined in Capnp.New.Basics estimateListAlloc :: Vector ByteString -> AllocHint (List Data) Source # | |
Marshal Data ByteString Source # | |
Defined in Capnp.New.Basics marshalInto :: RWCtx m s => Raw ('Mut s) Data -> ByteString -> m () Source # | |
EstimateAlloc Data ByteString Source # | |
Defined in Capnp.New.Basics estimateAlloc :: ByteString -> AllocHint Data Source # | |
Parse Data ByteString Source # | |
HasVariant "data_" 'Slot Value Data Source # | |
Defined in Capnp.Gen.Capnp.Schema.New | |
type ReprFor Data Source # | |
type ListAllocHint Data Source # | |
Defined in Capnp.New.Basics | |
type AllocHint Data Source # | |
Defined in Capnp.New.Basics |
The Cap'n Proto Text
type.
Instances
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.
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.
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.
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.
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
.
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.
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.
msgToLBS :: Message 'Const -> ByteString Source #
Convert an immutable message to a lazy ByteString
.
To convert a mutable message, freeze
it first.
msgToBS :: Message 'Const -> ByteString Source #
Convert an immutable message to a strict ByteString
.
To convert a mutable message, freeze
it first.
msgToValue :: (MonadThrow m, MonadReadMessage mut (LimitT m), MonadReadMessage mut m, FromStruct mut a) => Message mut -> m a Source #
Convert a message to a value.
bsToMsg :: MonadThrow m => ByteString -> m (Message 'Const) Source #
Convert a strict ByteString
to a message.
bsToValue :: (MonadThrow m, FromStruct 'Const a) => ByteString -> m a Source #
Convert a strict ByteString
to a value.
lbsToMsg :: MonadThrow m => ByteString -> m (Message 'Const) Source #
Convert a lazy ByteString
to a message.
lbsToValue :: (MonadThrow m, FromStruct 'Const a) => ByteString -> m a Source #
Convert a lazy ByteString
to a value.
valueToBuilder :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m Builder Source #
Convert a value to a Builder
.
valueToBS :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m ByteString Source #
Convert a value to a strict ByteString
.
valueToLBS :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m ByteString Source #
Convert a value to a lazy ByteString
.
valueToMsg :: (MonadLimit m, WriteCtx m s, Cerialize s a, ToStruct ('Mut s) (Cerial ('Mut s) a)) => a -> m (Message ('Mut s)) Source #
Convert a value to a message.
msgToRaw :: forall a m mut. (ReadCtx m mut, IsStruct a) => Message mut -> m (Raw mut a) Source #
Get the root pointer of a message, wrapped as a Raw
.
msgToParsed :: forall a m pa. (ReadCtx m 'Const, IsStruct a, Parse a pa) => Message 'Const -> m pa Source #
Get the root pointer of a message, as a parsed ADT.
bsToRaw :: (ReadCtx m 'Const, IsStruct a) => ByteString -> m (Raw 'Const a) Source #
Like msgToRaw
, but takes a (strict) bytestring.
bsToParsed :: (ReadCtx m 'Const, IsStruct a, Parse a pa) => ByteString -> m pa Source #
Like msgToParsed
, but takes a (strict) bytestring.
lbsToRaw :: (ReadCtx m 'Const, IsStruct a) => ByteString -> m (Raw 'Const a) Source #
Like msgToRaw
, but takes a (lazy) bytestring.
lbsToParsed :: (ReadCtx m 'Const, IsStruct a, Parse a pa) => ByteString -> m pa Source #
Like msgToParsed
, but takes a (lazzy) bytestring.
parsedToRaw :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m (Raw ('Mut s) a) Source #
Serialize the parsed form of a struct into its Raw
form, and make it the root
of its message.
parsedToMsg :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m (Message ('Mut s)) Source #
Serialize the parsed form of a struct into a message with that value as its root, returning the message.
parsedToBuilder :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m Builder Source #
Serialize the parsed form of a struct and return it as a Builder
parsedToLBS :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m ByteString Source #
Serialize the parsed form of a struct and return it as a lazy ByteString
parsedToBS :: forall a m pa s. (RWCtx m s, IsStruct a, Parse a pa) => pa -> m ByteString Source #
Serialize the parsed form of a struct and return it as a strict ByteString
hGetValue :: FromStruct 'Const a => Handle -> WordCount -> IO a Source #
reads a message from hGetValue
limit handlehandle
, returning its root object.
limit
is used as both a cap on the size of a message which may be read and, for types
in the high-level API, the traversal limit when decoding the message.
It may throw a Error
if there is a problem decoding the message,
or an IOError
raised by the underlying IO libraries.
sGetMsg :: Socket -> WordCount -> IO (Message 'Const) Source #
Like hGetMsg
, except that it takes a socket instead of a Handle
.
hPutValue :: (Cerialize RealWorld a, ToStruct ('Mut RealWorld) (Cerial ('Mut RealWorld) a)) => Handle -> a -> IO () Source #
putValue :: (Cerialize RealWorld a, ToStruct ('Mut RealWorld) (Cerial ('Mut RealWorld) a)) => a -> IO () Source #
sPutValue :: (Cerialize RealWorld a, ToStruct ('Mut RealWorld) (Cerial ('Mut RealWorld) a)) => Socket -> a -> IO () Source #
hGetParsed :: forall a pa. (IsStruct a, Parse a pa) => Handle -> WordCount -> IO pa Source #
Read a struct from the handle in its parsed form, using the supplied read limit.
sGetParsed :: forall a pa. (IsStruct a, Parse a pa) => Socket -> WordCount -> IO pa Source #
Read a struct from the socket in its parsed form, using the supplied read limit.
getParsed :: (IsStruct a, Parse a pa) => WordCount -> IO pa Source #
Read a struct from stdin in its parsed form, using the supplied read limit.
hPutParsed :: (IsStruct a, Parse a pa) => Handle -> pa -> IO () Source #
Write the parsed form of a struct to the handle
putParsed :: (IsStruct a, Parse a pa) => pa -> IO () Source #
Write the parsed form of a struct to stdout
sPutParsed :: (IsStruct a, Parse a pa) => Socket -> pa -> IO () Source #
Write the parsed form of a struct to the socket.
hGetRaw :: IsStruct a => Handle -> WordCount -> IO (Raw 'Const a) Source #
Read a struct from the handle using the supplied read limit, and return its root pointer.
getRaw :: IsStruct a => WordCount -> IO (Raw 'Const a) Source #
Read a struct from stdin using the supplied read limit, and return its root pointer.
sGetRaw :: IsStruct a => Socket -> WordCount -> IO (Raw 'Const a) Source #
Read a struct from the socket using the supplied read limit, and return its root pointer.
Instances
AsClient Client Source # | |
Eq (Client a) Source # | |
Show (Client a) Source # | |
ReprFor a ~ 'Ptr ('Just 'Cap) => IsClient (Client a) Source # | |
(TypeParam sturdyRef, TypeParam owner) => Parse (Persistent sturdyRef owner) (Client (Persistent sturdyRef owner)) Source # | |
Defined in Capnp.Gen.Capnp.Persistent.New | |
(TypeParam internalRef, TypeParam externalRef, TypeParam internalOwner, TypeParam externalOwner) => Parse (RealmGateway internalRef externalRef internalOwner externalOwner) (Client (RealmGateway internalRef externalRef internalOwner externalOwner)) Source # | |
Defined in Capnp.Gen.Capnp.Persistent.New parse :: ReadCtx m 'Const => Raw 'Const (RealmGateway internalRef externalRef internalOwner externalOwner) -> m (Client (RealmGateway internalRef externalRef internalOwner externalOwner)) Source # encode :: RWCtx m s => Message ('Mut s) -> Client (RealmGateway internalRef externalRef internalOwner externalOwner) -> m (Raw ('Mut s) (RealmGateway internalRef externalRef internalOwner externalOwner)) Source # |
A
is a reference to possibly-not-resolved result from
a method call.Pipeline
a
class (IsCap c, IsStruct p, IsStruct r) => HasMethod (name :: Symbol) c p r | name c -> p r where Source #
An instance
indicates that the interface
type HasMethod
name c p rc
has a method named name
with parameter type p
and
return type r
. The generated code includes instances of this
for each method in the schema.
methodByLabel :: Method c p r Source #
Instances
(TypeParam sturdyRef, TypeParam owner) => HasMethod "save" (Persistent sturdyRef owner) (Persistent'SaveParams sturdyRef owner) (Persistent'SaveResults sturdyRef owner) Source # | |
Defined in Capnp.Gen.Capnp.Persistent.New methodByLabel :: Method (Persistent sturdyRef owner) (Persistent'SaveParams sturdyRef owner) (Persistent'SaveResults sturdyRef owner) Source # | |
(TypeParam internalRef, TypeParam externalRef, TypeParam internalOwner, TypeParam externalOwner) => HasMethod "export" (RealmGateway internalRef externalRef internalOwner externalOwner) (RealmGateway'export'params internalRef externalRef internalOwner externalOwner) (Persistent'SaveResults externalRef externalOwner) Source # | |
Defined in Capnp.Gen.Capnp.Persistent.New methodByLabel :: Method (RealmGateway internalRef externalRef internalOwner externalOwner) (RealmGateway'export'params internalRef externalRef internalOwner externalOwner) (Persistent'SaveResults externalRef externalOwner) Source # | |
(TypeParam internalRef, TypeParam externalRef, TypeParam internalOwner, TypeParam externalOwner) => HasMethod "import_" (RealmGateway internalRef externalRef internalOwner externalOwner) (RealmGateway'import'params internalRef externalRef internalOwner externalOwner) (Persistent'SaveResults internalRef internalOwner) Source # | |
Defined in Capnp.Gen.Capnp.Persistent.New methodByLabel :: Method (RealmGateway internalRef externalRef internalOwner externalOwner) (RealmGateway'import'params internalRef externalRef internalOwner externalOwner) (Persistent'SaveResults internalRef internalOwner) Source # |
Represents a method on the interface type c
with parameter
type p
and return type r
.
Method | |
|
upcast :: (AsClient f, Coercible (f p) (f c), Super p c) => f c -> f p Source #
Upcast is a (safe) cast from an interface to one of its superclasses.
callB :: (AsClient f, IsCap c, IsStruct p, MonadSTM m) => Method c p r -> (forall s. PureBuilder s (Raw ('Mut s) p)) -> f c -> m (Pipeline r) Source #
Call a method. Use the provided PureBuilder
to construct the parameters.
callR :: (AsClient f, IsCap c, IsStruct p, MonadSTM m) => Method c p r -> Raw 'Const p -> f c -> m (Pipeline r) Source #
Call a method, supplying the parameters as a Raw
struct.
callP :: forall c p r f m pp. (AsClient f, IsCap c, IsStruct p, Parse p pp, MonadSTM m, MonadThrow m) => Method c p r -> pp -> f c -> m (Pipeline r) Source #
Call a method, supplying the parmaeters in parsed form.
pipe :: (IsStruct a, ReprFor b ~ 'Ptr pr) => Field k a b -> Pipeline a -> Pipeline b Source #
Project a pipeline to a struct onto one of its pointer fields.
waitPipeline :: forall a m pr. ('Ptr pr ~ ReprFor a, IsPtrRepr pr, MonadSTM m) => Pipeline a -> m (Raw 'Const a) Source #
Wait for the result of a pipeline, and return its value.
type TypeParam a = (IsPtr a, Parse a (Parsed a)) Source #
Constraints needed for a
to be a capnproto type parameter.
type Parsed a = ParsedByRepr (ReprFor a) a Source #
is the high-level/ADT representation of the capnproto
type Parsed
aa
. For struct types this is equivalent to
, but
we special case other types, such that e.g.
Parsed
a
= Parsed
Data
ByteString
.
Working with raw values
newtype Raw (mut :: Mutability) (a :: Type) Source #
A
is an Raw
mut aa
embedded in a capnproto message with mutability
mut
.
Instances
ReprFor a ~ 'Ptr ('Just 'Struct) => ToStruct mut (Raw mut a) Source # | |
ReprFor a ~ 'Ptr ('Just 'Struct) => FromStruct mut (Raw mut a) Source # | |
Defined in Capnp.Repr | |
(IsPtrRepr r, ReprFor a ~ 'Ptr r) => ToPtr s (Raw ('Mut s) a) Source # | |
(IsPtrRepr r, ReprFor a ~ 'Ptr r) => FromPtr mut (Raw mut a) Source # | |
Eq (Untyped mut (ReprFor a)) => Eq (Raw mut a) Source # | |
Read (Untyped mut (ReprFor a)) => Read (Raw mut a) Source # | |
Show (Untyped mut (ReprFor a)) => Show (Raw mut a) Source # | |
Generic (Untyped mut (ReprFor a)) => Generic (Raw mut a) Source # | |
MessageDefault (Raw 'Const a) 'Const => Default (Raw 'Const a) Source # | |
Defined in Capnp.Repr | |
MessageDefault (Untyped mut (ReprFor a)) mut => MessageDefault (Raw mut a) mut Source # | |
Defined in Capnp.Repr | |
HasMessage (Untyped mut (ReprFor a)) mut => HasMessage (Raw mut a) mut Source # | |
type Rep (Raw mut a) Source # | |
Defined in Capnp.Repr |
Working with raw lists
A phantom type denoting capnproto lists of type a
.
Instances
index :: forall a m mut. (ReadCtx m mut, Element (ReprFor a)) => Int -> Raw mut (List a) -> m (Raw mut a) Source #
gets the index
i listi
th element of the list.
setIndex :: forall a m s. (RWCtx m s, Element (ReprFor a)) => Raw ('Mut s) a -> Int -> Raw ('Mut s) (List a) -> m () Source #
sets the setIndex
value i listi
th element of list
to value
.
Working with fields
data Field (k :: FieldKind) a b Source #
is a first-class representation of a field of type Field
k a bb
within
an a
, where a
must be a struct type.
What sort of field is this? This corresponds to the slot/group variants
in the Field
type in schema.capnp. Mostly used at the type level with
the DataKinds
extension.
(Note that this has nothing to do with kinds in the usual type system sense of the word).
class IsStruct a => HasField (name :: Symbol) k a b | a name -> k b where Source #
An instance
indicates that the struct type HasField
name k a ba
has a field named name
with type b
(with k
being the FieldKind
for
the field). The generated code includes instances of this for each field
in the schema.
fieldByLabel :: Field k a b Source #
Instances
class IsStruct a => HasUnion a where Source #
An instance of HasUnion
indicates that the given type is a capnproto struct
(or group) with an anonymous union.
Which
is the abstract capnproto type of the union itself. Like
generated struct types (in this case a
), this is typically
uninhabitied, and used to define instances and/or act as a phantom type.
data RawWhich (mut :: Mutability) a Source #
Concrete view into a union embedded in a message. This will be a sum
type with other Raw
values as arguments.
unionField :: Field 'Slot a Word16 Source #
unionField
is a field holding the union's tag.
internalWhich :: ReadCtx m mut => Word16 -> Raw mut a -> m (RawWhich mut a) Source #
Helper used in generated code to extract a RawWhich
from its
surrounding struct.
Instances
class HasUnion a => HasVariant (name :: Symbol) k a b | a name -> k b where Source #
An instance 'HasVariant name k a b
indicates that the struct type a
has an anonymous union with a variant named name
, whose argument is of type
b
.
variantByLabel :: Variant k a b Source #
Instances
Working with messages
data Message (mut :: Mutability) Source #
A Cap'n Proto message, parametrized over its mutability.
Instances
Eq (Message mut) Source # | |
Thaw (Message 'Const) Source # | |
Defined in Capnp.Message thaw :: (PrimMonad m, PrimState m ~ s) => Message 'Const -> m (Mutable s (Message 'Const)) Source # freeze :: (PrimMonad m, PrimState m ~ s) => Mutable s (Message 'Const) -> m (Message 'Const) Source # unsafeThaw :: (PrimMonad m, PrimState m ~ s) => Message 'Const -> m (Mutable s (Message 'Const)) Source # unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => Mutable s (Message 'Const) -> m (Message 'Const) Source # | |
type Mutable s (Message 'Const) Source # | |
data Segment (mut :: Mutability) Source #
A segment in a Cap'n Proto message.
Instances
Eq (Segment mut) Source # | |
Thaw (Segment 'Const) Source # | |
Defined in Capnp.Message thaw :: (PrimMonad m, PrimState m ~ s) => Segment 'Const -> m (Mutable s (Segment 'Const)) Source # freeze :: (PrimMonad m, PrimState m ~ s) => Mutable s (Segment 'Const) -> m (Segment 'Const) Source # unsafeThaw :: (PrimMonad m, PrimState m ~ s) => Segment 'Const -> m (Mutable s (Segment 'Const)) Source # unsafeFreeze :: (PrimMonad m, PrimState m ~ s) => Mutable s (Segment 'Const) -> m (Segment 'Const) Source # | |
type Mutable s (Segment 'Const) Source # | |
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
.
class Monad m => MonadReadMessage mut m where Source #
A Message
is a (possibly read-only) capnproto message. It is
parameterized over a monad in which operations are performed.
numSegs :: Message mut -> m Int Source #
numSegs
gets the number of segments in a message.
numWords :: Segment mut -> m WordCount Source #
numWords
gets the number of words in a segment.
numCaps :: Message mut -> m Int Source #
numCaps
gets the number of capabilities in a message's capability
table.
internalGetSeg :: Message mut -> Int -> m (Segment mut) Source #
gets the segment at index internalGetSeg
message indexindex
in message
. Most callers should use the getSegment
wrapper, instead
of calling this directly.
internalGetCap :: Message mut -> Int -> m Client Source #
reads a capability from the message's
capability table, returning the client. does not check bounds. Callers
should use getCap instead.internalGetCap
cap index
slice :: WordCount -> WordCount -> Segment mut -> m (Segment mut) Source #
extracts a sub-section of the segment,
starting at index slice
start length segmentstart
, of length length
.
Instances
Monad m => MonadReadMessage 'Const m Source # | |
Defined in Capnp.Message numSegs :: Message 'Const -> m Int Source # numWords :: Segment 'Const -> m WordCount Source # numCaps :: Message 'Const -> m Int Source # internalGetSeg :: Message 'Const -> Int -> m (Segment 'Const) Source # internalGetCap :: Message 'Const -> Int -> m Client Source # slice :: WordCount -> WordCount -> Segment 'Const -> m (Segment 'Const) Source # | |
(PrimMonad m, s ~ PrimState m) => MonadReadMessage ('Mut s) m Source # | |
Defined in Capnp.Message numSegs :: Message ('Mut s) -> m Int Source # numWords :: Segment ('Mut s) -> m WordCount Source # numCaps :: Message ('Mut s) -> m Int Source # internalGetSeg :: Message ('Mut s) -> Int -> m (Segment ('Mut s)) Source # internalGetCap :: Message ('Mut s) -> Int -> m Client Source # slice :: WordCount -> WordCount -> Segment ('Mut s) -> m (Segment ('Mut s)) Source # |
newMessage :: WriteCtx m s => Maybe WordCount -> m (Message ('Mut s)) Source #
allocates a new empty message, with a single segment
having capacity newMessage
sizeHintsizeHint
. If sizeHint
is Nothing
, defaults to a sensible
value.
fromByteString :: ByteString -> Segment 'Const Source #
Convert a ByteString to a segment. O(1)
toByteString :: Segment 'Const -> ByteString Source #
Convert a segment to a byte string. O(1)
Building messages in pure code
data PureBuilder s a Source #
PureBuilder
is a monad transformer stack with the instnaces needed
manipulate mutable messages.
is morally equivalent
to PureBuilder
s aLimitT
(CatchT
(ST
s)) a
Instances
createPure :: (MonadThrow m, Thaw a) => WordCount -> (forall s. PureBuilder s (Mutable s a)) -> m a Source #
creates a capnproto value in pure code according
to createPure
limit mm
, then freezes it without copying. If m
calls throwM
then
createPure
rethrows the exception in the specified monad.
Canonicalizing messages
canonicalize :: (RWCtx m s, MonadReadMessage mutIn m) => Struct mutIn -> m (Message ('Mut s), Segment ('Mut s)) Source #
Return a canonicalized message with a copy of the given struct as its root. returns a (message, segment) pair, where the segment is the first and only segment of the returned message.
In addition to the usual reasons for failure when reading a message (traversal limit, malformed messages), this can fail if the message does not fit in a single segment, as the canonical form requires single-segment messages.
Implementing RPC servers
type MethodHandler p r = Raw 'Const p -> Fulfiller (Raw 'Const r) -> IO () Source #
Type alias for a handler for a particular rpc method.
class SomeServer a where Source #
Base class for things that can act as capnproto servers.
Nothing
shutdown :: a -> IO () Source #
Called when the last live reference to a server is dropped.
unwrap :: Typeable b => a -> Maybe b Source #
Try to extract a value of a given type. The default implementation
always fails (returns Nothing
). If an instance chooses to implement
this, it will be possible to use "reflection" on clients that point
at local servers to dynamically unwrap the server value. A typical
implementation will just call Typeable's cast
method, but this
needn't be the case -- a server may wish to allow local peers to
unwrap some value that is not exactly the data the server has access
to.
class (IsCap i, HasTypeId i) => Export i Source #
Generated interface types have instances of Export
, which allows a server
for that interface to be exported as a Client
.
type Server i :: * -> Constraint Source #
The constraint needed for a server to implement an interface;
if
is satisfied, Server
i ss
is a server for interface i
.
The code generator generates a type class for each interface, and
this will aways be an alias for that type class.
Instances
(TypeParam sturdyRef, TypeParam owner) => Export (Persistent sturdyRef owner) Source # | |
Defined in Capnp.Gen.Capnp.Persistent.New type Server (Persistent sturdyRef owner) :: Type -> Constraint Source # methodHandlerTree :: Server (Persistent sturdyRef owner) s => Proxy (Persistent sturdyRef owner) -> s -> MethodHandlerTree Source # | |
(TypeParam internalRef, TypeParam externalRef, TypeParam internalOwner, TypeParam externalOwner) => Export (RealmGateway internalRef externalRef internalOwner externalOwner) Source # | |
Defined in Capnp.Gen.Capnp.Persistent.New type Server (RealmGateway internalRef externalRef internalOwner externalOwner) :: Type -> Constraint Source # methodHandlerTree :: Server (RealmGateway internalRef externalRef internalOwner externalOwner) s => Proxy (RealmGateway internalRef externalRef internalOwner externalOwner) -> s -> MethodHandlerTree Source # |
export :: forall i s m. (MonadSTM m, Export i, Server i s, SomeServer s) => Supervisor -> s -> m (Client i) Source #
Export the server as a client for interface i
. Spawns a server thread
with its lifetime bound to the supervisor.
handleParsed :: (Parse p pp, IsStruct p, Parse r rr, IsStruct r) => (pp -> IO rr) -> MethodHandler p r Source #
Handle a method, working with the parsed form of parameters and results.
handleRaw :: (IsStruct p, IsStruct r) => (Raw 'Const p -> IO (Raw 'Const r)) -> MethodHandler p r Source #
Handle a method, working with the raw (unparsed) form of parameters and results.
methodUnimplemented :: MethodHandler p r Source #
MethodHandler
that always throws unimplemented.