Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file rPC.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180moduleRegistry:sig(** Handy central registry of all known interfaces, for logging. *)(** Used in the generated code to register the interfaces. *)valregister:interface_id:Uint64.t->name:string->(int->stringoption)->unit(** [pp_method] is a formatter for [(interface_id, method_id)] pairs.
It prints out qualified names, suitable for logging
(e.g. "Foo.bar") *)valpp_method:Format.formatter->Uint64.t*int->unitend=structtypeinterface={name:string;method_lookup:int->stringoption;}letinterfaces=Hashtbl.create7letregister~interface_id~namemethod_lookup=Hashtbl.addinterfacesinterface_id{name;method_lookup}letpp_methodf(interface_id,method_id)=matchHashtbl.findinterfacesinterface_idwith|exceptionNot_found->Format.fprintff"<interface %a>.<method-%d>"Uint64.printerinterface_idmethod_id|interface->matchinterface.method_lookupmethod_idwith|Somemethod_name->Format.fprintff"%s.%s"interface.namemethod_name|None->Format.fprintff"%s.<method-%d>"interface.namemethod_idendmoduleMethodID:sig(** A globally unique method ID, for a method on the interface ['interface],
which takes parameters of type ['request] and produces results of type
['response]. *)type('interface,'request,'response)tvalv:interface_id:Uint64.t->method_id:int->('interface,'req,'resp)tvalinterface_id:(_,_,_)t->Uint64.tvalmethod_id:(_,_,_)t->intvalpp:Format.formatter->(_,_,_)t->unitend=structtype('interface,'request,'response)t=Uint64.t*intletv~interface_id~method_id=(interface_id,method_id)letinterface_id:(_,_,_)t->Uint64.t=fstletmethod_id:(_,_,_)t->int=sndletppt=Registry.pp_methodtendmoduletypeS=sig(** Extends [MessageSig.S] with types for RPC. *)includeMessageSig.SmoduleService:sig(** The type of a method provided by the server application code.
This is used in the generated code for the service class type. *)type('a,'b)method_tendmoduleStructRef:sig(** A reference to a struct, which may not have arrived yet. *)type'atendmoduleCapability:sig(** A reference to an interface, which may be remote. *)type'atendmoduleUntyped:sig(** This module is only for use by the code generated by the capnp-ocaml
schema compiler. The generated code provides type-safe wrappers for
everything here. *)(** An untyped method. This will typically be something like
['a reader_t -> 'b StructRef.t]. i.e. the result of calling an
interface's method is a promise for the future result. *)typeabstract_method_t(** Cast a method to [abstract_method_t]. Typically this will be the identity function.
This is used in the generated code to ensure that all methods have the
same type for the dispatch function. *)valabstract_method:('aStructStorage.reader_t,'b)Service.method_t->abstract_method_t(** [struct_field t i] is a reference to the struct found at pointer index [i]
within the struct [t]. Used to implement the "_pipelined" accessors. *)valstruct_field:'aStructRef.t->int->'bStructRef.t(** [capability_field t i] is a reference to the capability found at pointer index [i]
within the struct [t]. Used to implement the "_pipelined" accessors. *)valcapability_field:'aStructRef.t->int->'bCapability.tclasstypegeneric_service=objectmethoddispatch:interface_id:Uint64.t->method_id:int->abstract_method_t(** Look up a method by ID. The schema compiler generates an implementation of this
that dispatches to the typed methods of the interface. *)methodrelease:unit(** Called when the service's ref-count drops to zero.
Implementations that hold other capabilities should override this to release them in turn. *)methodpp:Format.formatter->unit(** Used to identify the service in log messages.
The schema compiler generates a default that displays the service's name. *)end(** [local service] is a capability reference to a local service implemented by [service#dispatch].
Used by the generated functions with the same name (but a fixed type). *)vallocal:#generic_service->'aCapability.t(** Used in the generated code to get a capability from the attachments by index. *)valget_cap:MessageSig.attachments->Uint32.t->'aCapability.t(** Used in the generated code to store a capability in the attachments. Returns the new index. *)valadd_cap:MessageSig.attachments->'aCapability.t->Uint32.t(** Remove a capability from the attachments. Used if the interface is changed. *)valclear_cap:MessageSig.attachments->Uint32.t->unit(** Used to handle calls when the interface ID isn't known. *)valunknown_interface:interface_id:Uint64.t->abstract_method_t(** Used to handle calls when the method ID isn't known. *)valunknown_method:interface_id:Uint64.t->method_id:int->abstract_method_tendendmoduleNone(M:MessageSig.S)=struct(** A dummy RPC provider, for when the RPC features (interfaces) aren't needed. *)includeMmoduleUntyped=structtypeuntyped_struct=[`No_RPC_struct]typeabstract_method_t=[`No_RPC_payload]->untyped_structletdefine_method~interface_id~method_id=(interface_id,method_id)letabstract_methodx=xletstruct_field`No_RPC_struct_=`No_RPC_structletcapability_field`No_RPC_struct_=failwith"Can't pipeline with RPC.None!"letlocal_=failwith"Can't use local with RPC.None!"letget_cap_i=iletadd_cap_i=iletclear_cap__=()letunknown_interface~interface_id:__req=failwith"Unknown interface"letunknown_method~interface_id:_~method_id:__req=failwith"Unknown method"classtypegeneric_service=objectmethoddispatch:interface_id:Uint64.t->method_id:int->abstract_method_tmethodrelease:unitmethodpp:Format.formatter->unitendendmoduleStructRef=structtype'at=Untyped.untyped_structendmoduleCapability=structtype'at=Uint32.t(* Just the raw CapDescriptor table index. *)endmoduleService=structtype('a,'b)method_t=Untyped.abstract_method_tendend