-
Notifications
You must be signed in to change notification settings - Fork 212
fix(proc-macros): re-export tokio for params parsing #1361
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9495e6e
fix(proc-macros): re-export tokio and tests
niklasad1 f213f11
Update tests/proc-macro-core/src/lib.rs
niklasad1 bbdb79a
Update tests/proc-macro-core/Cargo.toml
niklasad1 f7081ee
Update core/src/lib.rs
niklasad1 8265fff
Update tests/proc-macro-core/src/lib.rs
niklasad1 33e9920
tests: custom params types
niklasad1 6558128
unify params
niklasad1 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [package] | ||
| name = "jsonrpsee-proc-macro-core" | ||
| description = "Test crate for the proc-macro API to make sure that it compiles with the core features" | ||
| version.workspace = true | ||
| authors.workspace = true | ||
| edition.workspace = true | ||
| license.workspace = true | ||
| publish = false | ||
|
|
||
| [dependencies] | ||
| jsonrpsee = { path = "../../jsonrpsee", features = ["server-core", "client-core", "macros"] } | ||
| serde = "1.0" |
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,73 @@ | ||
| //! Test module for the proc-macro API to make sure that it compiles with the core features. | ||
|
|
||
| use jsonrpsee::core::{async_trait, SubscriptionResult}; | ||
| use jsonrpsee::proc_macros::rpc; | ||
| use jsonrpsee::types::ErrorObjectOwned; | ||
| use jsonrpsee::{ConnectionDetails, PendingSubscriptionSink, SubscriptionMessage}; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| #[derive(Debug, Serialize, Deserialize)] | ||
| pub enum PubSubKind { | ||
| A, | ||
| B, | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, Deserialize)] | ||
| pub struct PubSubParams { | ||
| params: String, | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, Deserialize)] | ||
| pub struct PubSubItem { | ||
| result: String, | ||
| } | ||
|
|
||
| #[rpc(client, server)] | ||
| pub trait Api { | ||
| #[method(name = "sync_call")] | ||
| fn sync_call(&self, a: String) -> Result<String, ErrorObjectOwned>; | ||
|
|
||
| #[method(name = "async_call")] | ||
| async fn async_call(&self, a: String) -> Result<String, ErrorObjectOwned>; | ||
|
|
||
| #[subscription(name = "subscribe", item = PubSubItem)] | ||
| async fn sub(&self, kind: PubSubKind, p: PubSubParams) -> SubscriptionResult; | ||
|
|
||
| #[subscription(name = "subscribeSync", item = String)] | ||
| fn sync_sub(&self, a: String) -> SubscriptionResult; | ||
|
|
||
| #[method(name = "blocking", blocking)] | ||
| fn blocking_method(&self, a: String) -> Result<u16, ErrorObjectOwned>; | ||
|
|
||
| #[method(name = "raw", raw_method)] | ||
| async fn raw(&self, a: String) -> Result<u16, ErrorObjectOwned>; | ||
| } | ||
|
|
||
| #[async_trait] | ||
| impl ApiServer for () { | ||
| fn sync_call(&self, _: String) -> Result<String, ErrorObjectOwned> { | ||
| Ok("sync_call".to_string()) | ||
| } | ||
|
|
||
| async fn async_call(&self, _: String) -> Result<String, ErrorObjectOwned> { | ||
| Ok("async_call".to_string()) | ||
| } | ||
|
|
||
| async fn sub(&self, pending: PendingSubscriptionSink, _: PubSubKind, _: PubSubParams) -> SubscriptionResult { | ||
| let sink = pending.accept().await?; | ||
| sink.send(SubscriptionMessage::from("msg")).await?; | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn sync_sub(&self, _: PendingSubscriptionSink, _: String) -> SubscriptionResult { | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn blocking_method(&self, _: String) -> Result<u16, ErrorObjectOwned> { | ||
| Ok(42) | ||
| } | ||
|
|
||
| async fn raw(&self, _: ConnectionDetails, _: String) -> Result<u16, ErrorObjectOwned> { | ||
| Ok(42) | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.