package babel

  1. Overview
  2. Docs

Module Callee.Streamable_state_rpcSource

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

type ('q, 's, 'u) implementation := 'q -> ('s * 'u Async_kernel.Pipe.Reader.t) Core.Or_error.t Async_kernel.Deferred.t
Sourceval singleton : ('q, 's, 'u) Streamable.State_rpc.t -> ('q, 's, 'u) implementation t

Create a callee which can implement a given rpc.

Sourceval add : ('q, 's, 'u) implementation t -> rpc:('q, 's, 'u) Streamable.State_rpc.t -> ('q, 's, 'u) implementation t

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

Sourceval map_query : ('q1, 's, 'u) implementation t -> f:('q1 -> 'q2) -> ('q2, 's, 'u) implementation t

Map over the query type of a callee.

Sourceval map_state : ('q, 's1, 'u) implementation t -> f:('s2 -> 's1) -> ('q, 's2, 'u) implementation t

Map over the state type of a callee.

Sourceval map_update : ('q, 's, 'u1) implementation t -> f:('u2 -> 'u1) -> ('q, 's, 'u2) implementation t

Map over the update type of a callee.

Sometimes, Callee.Streamable_state_rpc.map_update is not sufficient. For example, sometimes it might not be possible to convert the response to the desired type, in which case it may be appropriate to drop the value from the pipe entirely. For such cases, use Callee.map_response instead. It gives you access to the pipe itself, not just the values inside it, allowing you to use something like Pipe.filter_map.

Sourceval filter_map_update : ('q, 's, 'u1) implementation t -> f:('u2 -> 'u1 option) -> ('q, 's, 'u2) implementation t

Map over the update type of a callee, possibly filtering out some updates.