Module Capnp_rpc_lwt.Sturdy_ref

type +'a t

An off-line (persistent) capability reference.

A sturdy ref contains all the information necessary to get a live reference to a service:

  • The network address of the hosting vat (e.g. TCP host and port)
  • A way to authenticate the hosting vat (e.g. a fingerprint of the vat's public key)
  • A way to identify the target service within the vat and prove permission to access it (e.g. a "Swiss number")
val connect : 'a t -> ('a Capability.t, Capnp_rpc.Exception.t) Stdlib.result Lwt.t

connect t returns a live reference to t's service.

val connect_exn : 'a t -> 'a Capability.t Lwt.t

connect_exn is a wrapper for connect that returns a failed Lwt thread on error.

val with_cap : 'a t -> ('a Capability.t -> ('b, [> `Capnp of Capnp_rpc.Exception.t ] as 'e) Lwt_result.t) -> ('b, 'e) Lwt_result.t

with_cap t f uses connect t to get a live-ref x, then does Capability.with_ref x f.

val with_cap_exn : 'a t -> ('a Capability.t -> 'b Lwt.t) -> 'b Lwt.t

with_cap_exn t f uses connect_exn t to get a live-ref x, then does Capability.with_ref x f.

val reader : ('a StructStorage.reader_t -> Capnp.MessageSig.ro Slice.t option) -> 'a StructStorage.reader_t -> Uri.t

reader accessor is a field accessor for reading a sturdy ref. e.g. if sr_get is a generated field accessor for an AnyPointer field, then reader Reader.Struct.sr_get is an accessor that treats it as a SturdyRef field. todo: This should really return a sturdy ref, not a URI, but that requires a change to the spec to add a sturdy ref cap-descriptor table entry type.

val builder : ('a StructStorage.builder_t -> Capnp.MessageSig.rw Slice.t) -> 'a StructStorage.builder_t -> _ t -> unit

builder setter converts a generated AnyPointer field setter setter to a SturdyRef setter. Use it to add a SturdyRef to a message with builder Params.sr_get params sr.

val cast : 'a t -> 'b t