paritytech / jsonrpc

Rust JSON-RPC implementation
MIT License
791 stars 274 forks source link

Clarify/Document `Params` parsing behavior #641

Open tomusdrw opened 3 years ago

tomusdrw commented 3 years ago

Follow up on the discussion in https://github.com/paritytech/jsonrpc/pull/640#discussion_r723297521

The clue is to clarify how we want the method implementation generated by derive to behave in case optional parameters are present.

Different cases:

  1. Positional parameters expected but there is no parameters or all parameters are optional.
  2. Named parameters expected but there is no parameters or all parameters are optional.
  3. Raw parameters expected.

The last case is simple - we simply let the user implementation to decide what to do. In case of (1) & (2) we need to clarify what kind of params are going to be accepted (empty array, empty object or Params::None).