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

Proc macro example broken: Expecting something like Result<Foo, Err> #1136

Closed
SuperFluffy opened this issue May 26, 2023 · 4 comments
Closed

Comments

@SuperFluffy
Copy link

SuperFluffy commented May 26, 2023

Compiling (a reduced version of) the jsonrpsee_proc_macros example is currently broken:

❯ cargo check
    Checking jsonrpeesee_derive_example v0.1.0 (/home/janis/dev/scratchpad/jsonrpeesee_derive_example)
error: Expecting something like 'Result<Foo, Err>' here, but got no generic args (eg no '<Foo,Err>').
 --> src/lib.rs:6:67
  |
6 |     async fn async_method(&self, param_a: u8, param_b: String) -> u16;
  |                                                                   ^^^

error: Expecting something like 'Result<Foo, Err>' here, but got no generic args (eg no '<Foo,Err>').
 --> src/lib.rs:8:30
  |
8 |     fn sync_method(&self) -> String;
  |                              ^^^^^^

error: could not compile `jsonrpeesee_derive_example` due to 2 previous errors

The reduced example (with cargo add jsonrpsee --features client,macros):

use jsonrpsee::proc_macros::rpc;

#[rpc(client, namespace = "foo")]
pub trait Rpc {
    #[method(name = "foo")]
    async fn async_method(&self, param_a: u8, param_b: String) -> u16;
    #[method(name = "bar")]
    fn sync_method(&self) -> String;
}

From a quick look at git-blame this PR introduced the change enforcing Result: #977

@niklasad1
Copy link
Member

Hey @SuperFluffy

Which jsonrpsee version are you using? This example does only work on v0.18

@SuperFluffy
Copy link
Author

SuperFluffy commented May 26, 2023

@niklasad1 0.18.2. I ran cargo add jsonrpsee 5 minutes ago.

[package]
name = "jsonrpeesee_derive_example"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
jsonrpsee = { version = "0.18.2", features = ["client", "macros"] }

@niklasad1
Copy link
Member

Ah, yeah you are running into #1067

For now you have to change the API to:

#[rpc(client, namespace = "foo")]
pub trait Rpc {
    #[method(name = "foo")]
    async fn async_method(&self, param_a: u8, param_b: String) -> Result<u16, Error>;
    #[method(name = "bar")]
    fn sync_method(&self) -> Result<String, Error>;
}

@niklasad1
Copy link
Member

Closing this duplicate to #1067

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

No branches or pull requests

2 participants