package babel

  1. Overview
  2. Docs

High level functions for working with callees in the style of Async.Rpc.Pipe_rpc.implement_direct.

This isn't quite a drop-in replacement because users will need to switch from Rpc.Pipe_rpc.Direct_stream_writer to Babel's Direct_stream_writer, but most of the same functions are supported.

module Direct_stream_writer : sig ... end
type ('q, 'r, 'e) implementation := 'q -> 'r Direct_stream_writer.t -> (unit, 'e) Core.Result.t Async_kernel.Deferred.t
val singleton : ('q, 'r, 'e) Async_rpc_kernel.Rpc.Pipe_rpc.t -> ('q, 'r, 'e) implementation t

Create a callee which can implement a given rpc.

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

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

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

Map over the query type of a callee.

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

Map over the response type of a callee.

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

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

val map_error : ('q, 'r, 'e1) implementation t -> f:('e2 -> 'e1) -> ('q, 'r, 'e2) implementation t

Map over the error type of a callee.

OCaml

Innovation. Community. Security.