Module jsonrpc

Module jsonrpc 

Source
Expand description

JSON-RPC primitives JSON-RPC 2.0 object definitions

Structs§

JsonError
A JSON-RPC error object
JsonErrorVal
A JSON-RPC error value (code and message)
JsonNotification
A JSON-RPC notification object
JsonRequest
A JSON-RPC request object
JsonResponse
A JSON-RPC response object
JsonSubscriber
A JSON-RPC subscriber for notifications

Enums§

ErrorCode
JSON-RPC error codes. The error codes [-32768, -32000] are reserved for predefined errors.
JsonResult
Wrapping enum around the available JSON-RPC object types

Functions§

parse_json_array_number
Parses the element at the specified index in a JsonValue::Array into an f64 (compatible with JsonValue::Number). Returns the number if successful, or an error if the parameter is missing, not an array, or is not a valid number.
parse_json_array_string
Parses the element at the specified index in a JsonValue::Array into a string. Returns the string if successful, or an error if the parameter is missing, not an array, or not a valid string.
parse_json_number
Parses a JsonValue parameter into a f64. Returns the number if successful or an error if the value is not a valid number.
parse_json_response_string
Attempts to parse a JsonResult, converting it into a JsonResponse and extracting a string result from it. Returns an error if conversion or extraction fails, and the extracted string on success.
parse_json_string
Parses a JsonValue parameter into a String. Returns the string if successful or an error if the value is not a valid string.
to_json_array
Converts the provided JSON-RPC parameters into an array of JSON values, returning a reference to the array if successful, or a JsonResult error containing a JsonError when the input is not a JSON array.
validate_empty_params
Validates whether the provided JSON parameter is an empty array or object, returning success if it is empty or an Error if it contains values.