Rust 为什么从Hyper板条箱多次导入失败?

Rust 为什么从Hyper板条箱多次导入失败?,rust,hyper,Rust,Hyper,我正在Rust中开发一个非常简单的HTTP客户端,它构建在hyper(,)机箱的顶部 当我尝试使用Cargo build(以及使用rustc src/main.rs)在新的Cargo项目中复制examples/client.rs文件时,我从hyper导入失败导致了多个错误 这是我的main.rs的顶部: extern crate hyper; use hyper::client::{Client, Request, Response, DefaultTransport as HttpStrea

我正在Rust中开发一个非常简单的HTTP客户端,它构建在
hyper
(,)机箱的顶部

当我尝试使用
Cargo build
(以及使用
rustc src/main.rs
)在新的Cargo项目中复制
examples/client.rs
文件时,我从
hyper
导入失败导致了多个错误

这是我的
main.rs
的顶部:

extern crate hyper;

use hyper::client::{Client, Request, Response, DefaultTransport as HttpStream};
use hyper::header::Connection;
use hyper::{Decoder, Encoder, Next};
除了一些注释外,该文件的其余部分与
hyper
存储库中的
examples/client.rs
文件相同

在编译时,我得到以下错误:

src/main.rs:10:48:10:78错误:未解析的导入`hyper::client::DefaultTransport`。'hyper::client`[E0432]中没有'DefaultTransport'
src/main.rs:10使用hyper::client::{client,Request,Response,DefaultTransport作为HttpStream};
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:10:48:10:78帮助:运行'rustc--explain E0432'查看详细说明
src/main.rs:12:13:12:20错误:未解析导入“hyper::Decoder”。“hyper”[E0432]中没有“解码器”
src/main.rs:12使用hyper:{Decoder,Encoder,Next};
^~~~~~~
src/main.rs:12:13:12:20帮助:运行'rustc--explain E0432'查看详细说明
src/main.rs:12:22:12:29错误:未解析导入“hyper::Encoder”。“hyper”[E0432]中没有“编码器”
src/main.rs:12使用hyper:{Decoder,Encoder,Next};
^~~~~~~
src/main.rs:12:22:12:29帮助:运行'rustc--explain E0432'查看详细说明
src/main.rs:12:31:12:35错误:未解析导入“hyper::Next”。“hyper”[E0432]中没有“Next”
src/main.rs:12使用hyper:{Decoder,Encoder,Next};
^~~~
src/main.rs:12:31:12:35帮助:运行'rustc--explain E0432'查看详细说明
src/main.rs:53:6:53:40错误:trait`hyper::client::Handler`不在范围[E0405]中
src/main.rs:53 impl hyper::client::转储处理程序{
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:53:6:53:40帮助:运行'rustc--explain E0405'查看详细说明
src/main.rs:53:6:53:40帮助:您可以将其导入作用域:`use hyper::server::Handler;`。
如果它可能导致此问题,以下是my
Cargo.toml
的内容:

name = "my_project"
version = "0.0.1"
authors = ["email@example.com"]

[dependencies]
getopts = "0.2"
hyper = "0.9.6"

[[bin]]
name = "my_project"
[dependencies]                                     
hyper = {git = "https://github.com/hyperium/hyper"}

有些导入实际上是有效的,因此假设存储库中的示例是最新的,我真的不知道是怎么回事。板条箱的源文件看起来像是暴露了所涉及的类型,但我对锈迹非常陌生,因此可能误读了文件。

您使用的示例来自主分支,与
0不兼容。9.6
版本。您可以查看分支机构上的示例,或直接从github使用
hyper
货运,在
货运上书写。toml

name = "my_project"
version = "0.0.1"
authors = ["email@example.com"]

[dependencies]
getopts = "0.2"
hyper = "0.9.6"

[[bin]]
name = "my_project"
[dependencies]                                     
hyper = {git = "https://github.com/hyperium/hyper"}

您使用的是哪个版本的hyper?@squiguy 0.9.6,最新版本可通过crates.io获得。使用
0.9.6
分支的实现可以工作。谢谢!