(De)serialization
A crucial responsibility of cuprate-rpc-types
is to provide the correct (de)serialization of types.
The input/output of Cuprate's RPC should match monerod
(as much as practically possible).
A simple example of this is that /get_height
should respond with the exact same data for both monerod
and Cuprate:
{
"hash": "7e23a28cfa6df925d5b63940baf60b83c0cbb65da95f49b19e7cf0ce7dd709ce",
"height": 2287217,
"status": "OK",
"untrusted": false
}
Behavior would be considered incompatible if any of the following were true:
- Fields are missing
- Extra fields exist
- Field types are incorrect (
string
instead ofnumber
, etc)
JSON
(De)serialization for JSON is implemented using serde
and serde_json
.
cuprate-rpc-interface
(the main crate responsible
for the actual output) uses serde_json
for JSON formatting. It is mostly the same formatting as monerod
, although there are slight differences.
Technically, the formatting of the JSON output is not handled by cuprate-rpc-types
, users are free to choose whatever formatting they desire.
Epee
(De)serialization for the epee binary format is handled by Cuprate's in-house cuprate-epee-encoding library.