package babel

  1. Overview
  2. Docs

High level functions for working with callees in the style of Streamable.Pipe_rpc.implement.

type ('q, 'r) implementation := 'q -> 'r Async_kernel.Pipe.Reader.t Core.Or_error.t Async_kernel.Deferred.t
val singleton : ('q, 'r) Streamable.Pipe_rpc.t -> ('q, 'r) implementation t

Create a callee which can implement a given rpc.

val add : ('q, 'r) implementation t -> rpc:('q, 'r) Streamable.Pipe_rpc.t -> ('q, 'r) implementation t

Extend a callee to be able to implement a given rpc.

val map_query : ('q1, 'r) implementation t -> f:('q1 -> 'q2) -> ('q2, 'r) implementation t

Map over the query type of a callee.

val map_response : ('q, 'r1) implementation t -> f:('r2 -> 'r1) -> ('q, 'r2) implementation t

Map over the response type of a callee.

Sometimes, Callee.Streamable_pipe_rpc.map_response is not sufficient. If you use Callee.map_response instead, you can access the pipe itself, not just the values inside it.

val filter_map_response : ('q, 'r1) implementation t -> f:('r2 -> 'r1 option) -> ('q, 'r2) implementation t

Map over the response type of a callee, possibly filtering out some responses.

OCaml

Innovation. Community. Security.