Proto/env: export RPC_directory.opt_register

This commit is contained in:
Grégoire Henry 2018-02-23 15:52:02 -05:00 committed by Benjamin Canou
parent 54b7d44da8
commit dc89432aad
2 changed files with 57 additions and 0 deletions

View File

@ -39,6 +39,12 @@ val register:
('params -> 'query -> 'input -> 'output tzresult Lwt.t) ->
'prefix directory
val opt_register:
'prefix directory ->
('meth, 'prefix, 'params, 'query, 'input, 'output) RPC_service.t ->
('params -> 'query -> 'input -> 'output option tzresult Lwt.t) ->
'prefix directory
val gen_register:
'prefix directory ->
('meth, 'prefix, 'params, 'query, 'input, 'output) RPC_service.t ->
@ -89,6 +95,42 @@ val register5:
('a -> 'b -> 'c -> 'd -> 'e -> 'q -> 'i -> 'o tzresult Lwt.t) ->
'prefix directory
val opt_register0:
unit directory ->
('m, unit, unit, 'q, 'i, 'o) RPC_service.t ->
('q -> 'i -> 'o option tzresult Lwt.t) ->
unit directory
val opt_register1:
'prefix directory ->
('m, 'prefix, unit * 'a, 'q , 'i, 'o) RPC_service.t ->
('a -> 'q -> 'i -> 'o option tzresult Lwt.t) ->
'prefix directory
val opt_register2:
'prefix directory ->
('m, 'prefix, (unit * 'a) * 'b, 'q , 'i, 'o) RPC_service.t ->
('a -> 'b -> 'q -> 'i -> 'o option tzresult Lwt.t) ->
'prefix directory
val opt_register3:
'prefix directory ->
('m, 'prefix, ((unit * 'a) * 'b) * 'c, 'q , 'i, 'o) RPC_service.t ->
('a -> 'b -> 'c -> 'q -> 'i -> 'o option tzresult Lwt.t) ->
'prefix directory
val opt_register4:
'prefix directory ->
('m, 'prefix, (((unit * 'a) * 'b) * 'c) * 'd, 'q , 'i, 'o) RPC_service.t ->
('a -> 'b -> 'c -> 'd -> 'q -> 'i -> 'o option tzresult Lwt.t) ->
'prefix directory
val opt_register5:
'prefix directory ->
('m, 'prefix, ((((unit * 'a) * 'b) * 'c) * 'd) * 'e, 'q , 'i, 'o) RPC_service.t ->
('a -> 'b -> 'c -> 'd -> 'e -> 'q -> 'i -> 'o option tzresult Lwt.t) ->
'prefix directory
val gen_register0:
unit directory ->
('m, unit, unit, 'q, 'i, 'o) RPC_service.t ->

View File

@ -290,6 +290,14 @@ module Make (Context : CONTEXT) = struct
| Ok o -> RPC_answer.return o
| Error e -> RPC_answer.fail e)
let opt_register dir service handler =
gen_register dir service
(fun p q i ->
handler p q i >>= function
| Ok (Some o) -> RPC_answer.return o
| Ok None -> RPC_answer.not_found
| Error e -> RPC_answer.fail e)
let lwt_register dir service handler =
gen_register dir service
(fun p q i ->
@ -305,6 +313,13 @@ module Make (Context : CONTEXT) = struct
let register4 root s f = register root s (curry (S (S (S (S Z)))) f)
let register5 root s f = register root s (curry (S (S (S (S (S Z))))) f)
let opt_register0 root s f = opt_register root s (curry Z f)
let opt_register1 root s f = opt_register root s (curry (S Z) f)
let opt_register2 root s f = opt_register root s (curry (S (S Z)) f)
let opt_register3 root s f = opt_register root s (curry (S (S (S Z))) f)
let opt_register4 root s f = opt_register root s (curry (S (S (S (S Z)))) f)
let opt_register5 root s f = opt_register root s (curry (S (S (S (S (S Z))))) f)
let gen_register0 root s f = gen_register root s (curry Z f)
let gen_register1 root s f = gen_register root s (curry (S Z) f)
let gen_register2 root s f = gen_register root s (curry (S (S Z)) f)