Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RpcParams::parse to handle optional params & validate JSON-RPC spec #380

Closed
maciejhirsz opened this issue Jun 15, 2021 · 1 comment
Closed

Comments

@maciejhirsz
Copy link
Contributor

Currently RpcParams is just using serde_json::from_str, which creates two problems:

  1. There is no way to handle deserializing a tuple with optional params, e.g.: (A, Option<B>) from json ["some type that creates A"].
  2. It is technically possible to allow param types other than those allowed in the spec ("params" must be either null, an object with named params, or an array).

One way to do that would be to create tuple types for different numbers of params (Params1<A>(A), Params2<A, B>(A, B), etc., up to some fixed limit like 10), and then manually implementing Deserialize on them (with macros for all the variants). This would also remove the need to have RpcParams::one separate from RpcParams::parse.

@maciejhirsz
Copy link
Contributor Author

Solved by #401.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant