package capnp-rpc

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

This module defines a calling convention for invoking methods on objects. The objects could be remote, but this module doesn't define anything related to networks. These types are generated automatically from WIRE by Core_types.

module Wire : S.WIRE

The core RPC logic can be used with different serialisation systems. The appropriate types should be provided here.

type 'a or_error = ('a, Error.t) Stdlib.result
class type base_ref = object ... end

Common methods for struct_ref and cap.

val pp : base_ref Fmt.t
val inc_ref : base_ref -> unit

inc_ref x increases x's ref-count by one.

val dec_ref : base_ref -> unit

dec_ref x decreases x's ref-count by one.

class type struct_ref = object ... end

The result of a call, which may not have arrived yet. It can be used to pipeline calls to capabilities that we hope will be returned in the results.

class type cap = object ... end

A capability reference to an object that can handle calls. We might not yet know its final location, but we may be able to pipeline messages to it anyway.

class type struct_resolver = object ... end

A struct_resolver can be used to resolve some promise.

module Attachments : sig ... end
module Request_payload : S.PAYLOAD with type t = Wire.Request.t and type cap := cap and type path := Wire.Path.t

The payload of a request message.

module Response_payload : S.PAYLOAD with type t = Wire.Response.t and type cap := cap and type path := Wire.Path.t

The payload of a response message.

class virtual ref_counted : object ... end

A mix-in to help with writing reference-counted objects. It will call self#release when the ref-count reaches zero.

class virtual service : object ... end

A convenience base class for creating local services. The capability is always resolved, and the default release method does nothing.

val null : cap

A (broken) capability representing a missing pointer. Any attempt to call it will return an error.

return x is a resolved struct_ref with successful resolution x.

val fail : ?ty:Exception.ty -> ('a, Stdlib.Format.formatter, unit, struct_ref) Stdlib.format4 -> 'a

fail fmt is a struct_ref that is broken with the given capnp exception message.

val broken_cap : Exception.t -> cap

broken_cap ex is a cap that is broken with the given exception.

val broken_struct : Error.t -> struct_ref

broken_struct err is a struct_ref that is broken with the given error.

resolved x is a resolved struct_ref with resolution x.

val resolve_payload : struct_resolver -> Response_payload.t or_error -> unit

resolve_payload r x is r#resolve (resolved x). r takes ownership of x.

val resolve_ok : struct_resolver -> Wire.Response.t -> unit

resolve_ok r msg is resolve_payload r (Ok msg). r takes ownership of msg.

val resolve_exn : struct_resolver -> Exception.t -> unit

resolve_exn r exn is resolve_payload r (Error (`Exception exn)).

val when_broken : (Exception.t -> unit) -> cap -> unit

when_broken fn x calls fn problem when x becomes broken. If x is already broken, fn is called immediately. If x can never become broken (e.g. it is a near ref), this does nothing.

OCaml

Innovation. Community. Security.