-
Notifications
You must be signed in to change notification settings - Fork 265
Client call with named params #541
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
Merged
tomusdrw
merged 26 commits into
paritytech:master
from
willemolding:client-call-with-named-params
Mar 23, 2020
Merged
Changes from 7 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
4bf380d
add support for json objects in TypedClient.call_method
willemolding c65efae
adds named params switch to #[rpc] method annotation
willemolding 187078a
add generating of map style params in macro
willemolding 167612f
prevent creating a server when using the named_params switch
willemolding 4cfa00b
add test for attempt to derive with named_params on server. refactors…
willemolding f158a7f
adds test that correct params object is generated
willemolding b0fefbc
apply cargo fmt
willemolding 2e266c7
adds ParamStyle enum and conversions. Parses this from meta
willemolding 7baf3be
updates existing tests
willemolding 097276c
adds client side support for raw params
willemolding 66488b2
adds compiler error on invalid params value
willemolding 95a945c
add client tests
willemolding 2d20978
adds global switch to trait attribute
willemolding 510048f
add logic to override code generation with default from top level
willemolding a6850ae
adds error on changing trait default when generating server with inco…
willemolding d750f40
adds tests for preventing server generation with named params
willemolding 36bab4e
Update derive/src/rpc_attr.rs
willemolding 4721ce2
Update derive/src/rpc_trait.rs
willemolding e7abc09
remove unwrap and throw useful compile time error
willemolding 38bb7f0
fixes error, notifies that server also supports raw params
willemolding 0d4bb3c
add placeholder for future support for named params server side
willemolding 82257ea
remove raw_params from examples and replace with params = raw
willemolding 1933993
run cargo fmt
willemolding e7e0cd5
add deprecation message placeholder
willemolding 2c69f44
bump and lock quote version
willemolding 15a5b8b
rollback quote to 1.0.1
willemolding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| use jsonrpc_derive::rpc; | ||
|
|
||
| #[rpc] | ||
| pub trait Rpc { | ||
| /// Returns a protocol version | ||
| #[rpc(name = "add", named_params)] | ||
| fn add(&self, a: u32, b: u32) -> Result<String>; | ||
| } | ||
|
|
||
| fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| error: The named_params switch can only be used to generate a client (on a trait annotated with #[rpc(client)]). At this time the server does not support named parameters. | ||
| --> $DIR/attr-named-params-on-server.rs:4:1 | ||
| | | ||
| 4 | / pub trait Rpc { | ||
| 5 | | /// Returns a protocol version | ||
| 6 | | #[rpc(name = "add", named_params)] | ||
| 7 | | fn add(&self, a: u32, b: u32) -> Result<String>; | ||
| 8 | | } | ||
| | |_^ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to specify
named_paramsin the trait level attribute instead? On the one hand it's good to have the fine grained control - but in practice wouldn't all methods be either named or positional?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have
raw_paramson the method level. I think this is a good idea to have it here, but an additional attribute on the trait level would be cool tool, especially in the future if we implement server side as well.