-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make it possible to override
method name
in subscriptions (#568)
* feat: override `method` subscription notif * Arrow syntax for overwrites (#569) * check that unique notifs are used * check that custom sub name is unique * cargo fmt * address grumbles * Update proc-macros/src/rpc_macro.rs * commit added tests * Update proc-macros/src/render_server.rs Co-authored-by: David <dvdplm@gmail.com> * Update proc-macros/src/render_server.rs Co-authored-by: David <dvdplm@gmail.com> * Update proc-macros/src/rpc_macro.rs Co-authored-by: David <dvdplm@gmail.com> * Update proc-macros/src/rpc_macro.rs Co-authored-by: David <dvdplm@gmail.com> * Update utils/src/server/rpc_module.rs Co-authored-by: David <dvdplm@gmail.com> * grumbles * fix long lines * Update utils/src/server/rpc_module.rs Co-authored-by: David <dvdplm@gmail.com> * Update utils/src/server/rpc_module.rs Co-authored-by: David <dvdplm@gmail.com> * Update proc-macros/src/rpc_macro.rs Co-authored-by: David <dvdplm@gmail.com> * Update proc-macros/src/render_server.rs Co-authored-by: David <dvdplm@gmail.com> * Update proc-macros/src/render_server.rs Co-authored-by: David <dvdplm@gmail.com> * more grumbles Co-authored-by: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com> Co-authored-by: David <dvdplm@gmail.com>
- Loading branch information
1 parent
0e46b5c
commit 9c6fd4b
Showing
17 changed files
with
167 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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
12 changes: 12 additions & 0 deletions
12
proc-macros/tests/ui/incorrect/sub/sub_dup_name_override.rs
This file contains 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,12 @@ | ||
use jsonrpsee::{proc_macros::rpc, types::RpcResult}; | ||
|
||
// Subscription method must not use the same override name. | ||
#[rpc(client, server)] | ||
pub trait DupOverride { | ||
#[subscription(name = "one" => "override", item = u8)] | ||
fn one(&self) -> RpcResult<()>; | ||
#[subscription(name = "two" => "override", item = u8)] | ||
fn two(&self) -> RpcResult<()>; | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
proc-macros/tests/ui/incorrect/sub/sub_dup_name_override.stderr
This file contains 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,5 @@ | ||
error: "override" is already defined | ||
--> tests/ui/incorrect/sub/sub_dup_name_override.rs:9:5 | ||
| | ||
9 | fn two(&self) -> RpcResult<()>; | ||
| ^^^ |
This file contains 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 jsonrpsee::{proc_macros::rpc, types::RpcResult}; | ||
|
||
// Subscription method name conflict with notif override. | ||
#[rpc(client, server)] | ||
pub trait DupName { | ||
#[subscription(name = "one" => "one", item = u8)] | ||
fn one(&self) -> RpcResult<()>; | ||
} | ||
|
||
fn main() {} |
This file contains 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,5 @@ | ||
error: "one" is already defined | ||
--> tests/ui/incorrect/sub/sub_name_override.rs:7:5 | ||
| | ||
7 | fn one(&self) -> RpcResult<()>; | ||
| ^^^ |
This file contains 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 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 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
Oops, something went wrong.