Search code examples
rustjson-rpc

Named JSON-RPC params using jsonrpc Rust crate


I need to build JSON-RPC server that supports request params by name rather than by position. This should allow mapping params into structures for sake of maintainability and extensibility.

As far as I can see jsonrpc-derive crate doesn't support code generation for this scenario if not to pass such a structure as a first parameter (which will uglify my API specification). So I have to define handlers via add_method(), serialize Params::Map back into JSON and deserialize again into my param structure. This looks pretty ridiculous and inefficient. Do I have another alternative?


Solution

  • It looks like after client-side named parameters were added a proposal was made for client-side named parameters, however it stalled and was never merged.

    However the entire crate seems to have stalled / died. If you're building a json-rpc server, maybe you just... don't need to bother with it anywa? jsonrpc is not exactly a complex format.