我正在开发一个使用reqwest和self_update的CLI应用程序。 self_update也使用reqwest。 我希望我的应用程序使用rustls而不是拉取openssl依赖项。 Cargo.toml允许选择依赖项的功能:
[dependencies.reqwest]
version = "0.10"
default-features = false
features = ["rustls-tls", "json", "blocking"]
如果子依赖项也能正常工作那就太棒了:
[dependencies.self_update.reqwest]
version = "0.10"
default-features = false
features = ["rustls-tls", "json", "blocking"]
我也查看了replace section,但只有在我分支代码时才能像这样运行:
"reqwest:0.10.1" = { branch = "rustls", git = "https://github.com/ctaggart/reqwest" }
但我想要的是默认功能和支持功能:
"reqwest:0.10.1" = { tag="v0.10.1", git = "https://github.com/seanmonstar/reqwest", default-features = false, features = ["rustls-tls", "json", "blocking"] }
我该如何使用Cargo配置Reqwest、Tokio或任何其他高度可配置的非直接依赖包的功能?
reqwest
副本。 - mcartonself_update
拉取openssl依赖项,这是reqwest
的默认功能? - Cameron Taggartself_update
本身必须具备此功能。Cargo无法知道从子依赖项中删除功能是否安全,因为您的依赖项可能实际上使用该功能。 - mcartonself_update
添加一个rustls
特性,但是 cargo 不支持基于特性的不同依赖项。https://github.com/rust-lang/cargo/issues/5954 我认为将每个可选特性都向上传递到消费库会是一种奇怪的设计。 - Cameron Taggartself_update
添加了一个重新导出reqwest
功能的特性。https://github.com/jaemk/self_update/pull/43/files 问题已解决! - Cameron Taggart