zefchain / serde-reflection

Rust libraries and tools to help with interoperability and testing of serialization formats based on Serde.
Apache License 2.0
137 stars 26 forks source link

[Feature Request] Minimize dependencies of `serde-generate` #25

Closed weiznich closed 1 year ago

weiznich commented 1 year ago

🚀 Feature Request

Motivation

cargo tree currently reports the following dependencies for serde-generate:

serde-generate v0.24.0
├── bcs v0.1.4
│   ├── serde v1.0.148
│   │   └── serde_derive v1.0.148 (proc-macro)
│   │       ├── proc-macro2 v1.0.47
│   │       │   └── unicode-ident v1.0.5
│   │       ├── quote v1.0.21
│   │       │   └── proc-macro2 v1.0.47 (*)
│   │       └── syn v1.0.104
│   │           ├── proc-macro2 v1.0.47 (*)
│   │           ├── quote v1.0.21 (*)
│   │           └── unicode-ident v1.0.5
│   └── thiserror v1.0.37
│       └── thiserror-impl v1.0.37 (proc-macro)
│           ├── proc-macro2 v1.0.47 (*)
│           ├── quote v1.0.21 (*)
│           └── syn v1.0.104 (*)
├── bincode v1.3.3
│   └── serde v1.0.148 (*)
├── heck v0.3.3
│   └── unicode-segmentation v1.10.0
├── include_dir v0.6.2
│   ├── glob v0.3.0
│   ├── include_dir_impl v0.6.2 (proc-macro)
│   │   ├── anyhow v1.0.66
│   │   ├── proc-macro-hack v0.5.19 (proc-macro)
│   │   ├── proc-macro2 v1.0.47 (*)
│   │   ├── quote v1.0.21 (*)
│   │   └── syn v1.0.104 (*)
│   └── proc-macro-hack v0.5.19 (proc-macro)
├── maplit v1.0.2
├── phf v0.10.1
│   ├── phf_macros v0.10.0 (proc-macro)
│   │   ├── phf_generator v0.10.0
│   │   │   ├── phf_shared v0.10.0
│   │   │   │   └── siphasher v0.3.10
│   │   │   └── rand v0.8.5
│   │   │       ├── libc v0.2.137
│   │   │       ├── rand_chacha v0.3.1
│   │   │       │   ├── ppv-lite86 v0.2.17
│   │   │       │   └── rand_core v0.6.4
│   │   │       │       └── getrandom v0.2.8
│   │   │       │           ├── cfg-if v1.0.0
│   │   │       │           └── libc v0.2.137
│   │   │       └── rand_core v0.6.4 (*)
│   │   ├── phf_shared v0.10.0 (*)
│   │   ├── proc-macro-hack v0.5.19 (proc-macro)
│   │   ├── proc-macro2 v1.0.47 (*)
│   │   ├── quote v1.0.21 (*)
│   │   └── syn v1.0.104 (*)
│   ├── phf_shared v0.10.0 (*)
│   └── proc-macro-hack v0.5.19 (proc-macro)
├── serde v1.0.148 (*)
├── serde-reflection v0.3.6
│   ├── once_cell v1.16.0
│   ├── serde v1.0.148 (*)
│   └── thiserror v1.0.37 (*)
├── serde_bytes v0.11.8
│   └── serde v1.0.148 (*)
├── serde_yaml v0.8.26
│   ├── indexmap v1.9.2
│   │   └── hashbrown v0.12.3
│   │   [build-dependencies]
│   │   └── autocfg v1.1.0
│   ├── ryu v1.0.11
│   ├── serde v1.0.148 (*)
│   └── yaml-rust v0.4.5
│       └── linked-hash-map v0.5.6
├── structopt v0.3.26
│   ├── clap v2.34.0
│   │   ├── ansi_term v0.12.1
│   │   ├── atty v0.2.14
│   │   │   └── libc v0.2.137
│   │   ├── bitflags v1.3.2
│   │   ├── strsim v0.8.0
│   │   ├── textwrap v0.11.0
│   │   │   └── unicode-width v0.1.10
│   │   ├── unicode-width v0.1.10
│   │   └── vec_map v0.8.2
│   ├── lazy_static v1.4.0
│   └── structopt-derive v0.4.18 (proc-macro)
│       ├── heck v0.3.3 (*)
│       ├── proc-macro-error v1.0.4
│       │   ├── proc-macro-error-attr v1.0.4 (proc-macro)
│       │   │   ├── proc-macro2 v1.0.47 (*)
│       │   │   └── quote v1.0.21 (*)
│       │   │   [build-dependencies]
│       │   │   └── version_check v0.9.4
│       │   ├── proc-macro2 v1.0.47 (*)
│       │   ├── quote v1.0.21 (*)
│       │   └── syn v1.0.104 (*)
│       │   [build-dependencies]
│       │   └── version_check v0.9.4
│       ├── proc-macro2 v1.0.47 (*)
│       ├── quote v1.0.21 (*)
│       └── syn v1.0.104 (*)
└── textwrap v0.13.4
    ├── smawk v0.3.1
    └── unicode-width v0.1.10

Ideally serde-generate would provide an API that put dependencies behind different feature flags, so that not everything is required if only a small part of the crate is used.

Especially that includes the following dependencies:

I'm not sure about other dependencies like textwrap, heck, serde_bytes, include_dir, maplit and phf.

Pitch

Describe the solution you'd like Put parts of the API behind feature flags, so that users can choose what to use + what gate corresponding dependencies on these flags.

Describe alternatives you've considered

Do not change anything and pull in potentially unneeded dependencies.

Are you willing to open a pull request? (See CONTRIBUTING)

I would be willing to contribute a PR for that

Additional context

weiznich commented 1 year ago

That's fixed by https://github.com/zefchain/serde-reflection/pull/30