Cap'n Proto is a capability-based RPC system with bindings for many languages
Library capnp-rpc-unix
Module Capnp_rpc_unix . Vat
type t

A local vat.

val create : ?switch:Lwt_switch.t -> ?tags:Logs.Tag.set -> ?restore:Capnp_rpc_lwt.Restorer.t -> ?address:Network.Address.t -> secret_key:Capnp_rpc_lwt.Auth.Secret_key.t Lazy.t -> Network.t -> t

create ~switch ~restore ~address ~secret_key network is a new vat that uses restore to restore sturdy refs hosted at this vat to live capabilities for peers. The vat will suggest that other parties connect to it using address. Turning off the switch will disconnect any active connections.

val add_connection : t -> switch:Lwt_switch.t -> mode:[ `Accept | `Connect ] -> Capnp_rpc_lwt.Endpoint.t -> CapTP.t Lwt.t

add_connection t ~switch ~mode endpoint runs the CapTP protocol over endpoint, which is a connection to another vat. When the connection ends, switch will be turned off, and turning off switch will end the connection. mode is used if two vats connect to each other at the same time to decide which connection to drop. Use `Connect if t initiated the new connection. Note that add_connection may return an existing connection.

val public_address : t -> Network.Address.t option

public_address t is the address that peers should use when connecting to this vat to locate and authenticate it.

sturdy_ref t service_id is a sturdy ref for service_id, hosted at this vat. Fails if this vat does not accept incoming connections.

val export : t -> 'a Capnp_rpc_lwt.Sturdy_ref.t -> Uri.t

export t sr turns sr into a URI, which can be displayed and imported into another vat.

val sturdy_uri : t -> Capnp_rpc_lwt.Restorer.Id.t -> Uri.t

sturdy_uri t id is sturdy_ref t id |> export t.

val import : t -> Uri.t -> ( 'a Capnp_rpc_lwt.Sturdy_ref.t, [> `Msg of string ] ) result

import t uri parses uri as a "capnp://" URI.

val import_exn : t -> Uri.t -> 'a Capnp_rpc_lwt.Sturdy_ref.t

import_exn is a wrapper for import that raises an exception if it fails.

val dump : t Fmt.t