package capnp-rpc

  1. Overview
  2. Docs

Module Capnp_rpc.Core_typesSource

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.

Parameters

module W : S.WIRE

Signature

Sourcemodule Wire = W
Sourcetype 'a or_error = ('a, Error.t) result
Sourceclass type base_ref = object ... end

Common methods for struct_ref and cap.

Sourceval inc_ref : base_ref -> unit

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

Sourceval dec_ref : base_ref -> unit

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

Sourceclass 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.

Sourceclass 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.

Sourceclass type struct_resolver = object ... end

A struct_resolver can be used to resolve some promise.

Sourcemodule Attachments : sig ... end
Sourcemodule 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.

Sourcemodule 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.

Sourceclass 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.

Sourceclass virtual service : object ... end

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

Sourceval 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.

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

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

Sourceval broken_cap : Exception.t -> cap

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

Sourceval 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.

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

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

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

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

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

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

Sourceval 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.