Skip to content

#[rpc] macro in derive has dependencies which are not propagated into consuming projects #481

@fwcd

Description

@fwcd

I am trying to implement the basic example using derive from the README. Since the code snippet only seems to require jsonrpc-core and jsonrpc-derive, I did not include any other dependencies in Cargo.toml:

[dependencies]
jsonrpc-core = "13.0.0"
jsonrpc-derive = "13.0.0"

The compiler, however, yields an error that a crate named serde is required too:

error: Could not find `serde` in `dependencies` or `dev-dependencies` in `...\Cargo.toml`!
 --> src\main.rs:4:1
  |
4 | #[rpc]
  | ^^^^^^

Indeed does the #[rpc] macro have a dependency on serde:

mod #mod_name_ident {
use #serde_name as _serde;
use #core_name as _jsonrpc_core;
use super::*;

serde is only listed as a dev-dependency though, so it will not propagate into projects consuming the library:

[dev-dependencies]
jsonrpc-core = { version = "13.0", path = "../core" }
jsonrpc-core-client = { version = "13.0", path = "../core-client" }
jsonrpc-pubsub = { version = "13.0", path = "../pubsub" }
jsonrpc-tcp-server = { version = "13.0", path = "../tcp" }
futures = "~0.1.6"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = "0.1"
trybuild = "1.0"

Adding serde explicitly to my Cargo.toml did fix the issue, but brought up another missing dependency (jsonrpc-core-client) which, again, had to be added manually despite being used by the #[rpc] macro.

Am I missing something? Would it be possible to clarify which dependencies have to be provided manually when using jsonrpc-derive?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions