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

Passing params as struct using derive-macro #681

Open
ababo opened this issue Oct 23, 2023 · 1 comment
Open

Passing params as struct using derive-macro #681

ababo opened this issue Oct 23, 2023 · 1 comment

Comments

@ababo
Copy link

ababo commented Oct 23, 2023

Is there a way to pass method params through single struct (for sake of extensibility and flexibility), i.e. something like

#[rpc]
pub trait ServerApi {
    fn foo(&self, params: FooParams) -> Result<FooReply>;
}

struct FooParams {
    bar: String,
}

So now I can call {"jsonrpc":"2.0","id":123,"method":"foo","params":{"bar": "buzz"}}.

@ababo
Copy link
Author

ababo commented Oct 24, 2023

Moreover even without the derive macro there's no way to handle named params without Map->JSON->struct conversion which is inefficient and ugly. Did I miss something?

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

1 participant