json-rpc.capnp (1295B)
1 @0xd04299800d6725ba; 2 3 $import "/capnp/c++.capnp".namespace("capnp::json"); 4 5 using Json = import "json.capnp"; 6 7 struct RpcMessage { 8 jsonrpc @0 :Text; 9 # Must always be "2.0". 10 11 id @1 :Json.Value; 12 # Correlates a request to a response. Technically must be a string or number. Our implementation 13 # will always use a number for calls it initiates, and will reflect IDs of any type for calls 14 # it receives. 15 # 16 # May be omitted when caller doesn't care about the response. The implementation will omit `id` 17 # and return immediately when calling methods with the annotation `@notification` (defined in 18 # `json.capnp`). The `@notification` annotation only matters for outgoing calls; for incoming 19 # calls, it's the client's decision whether it wants to receive the response. 20 21 method @2 :Text; 22 # Method name. Only expected when `params` is sent. 23 24 union { 25 none @3 :Void $Json.name("!missing params, result, or error"); 26 # Dummy default value of union, to detect when none of the fields below were received. 27 28 params @4 :Json.Value; 29 # Initiates a call. 30 31 result @5 :Json.Value; 32 # Completes a call. 33 34 error @6 :Error; 35 # Completes a call throwing an exception. 36 } 37 38 struct Error { 39 code @0 :Int32; 40 message @1 :Text; 41 data @2 :Json.Value; 42 } 43 }