为什么从Hyper crate多次导入失败?

朱尔斯

我正在Rust的一个非常简单的HTTP客户端上工作,该客户端基于hyperGitHubcrates.io)条板箱构建

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

这是我的顶部main.rs

extern crate hyper;

use hyper::client::{Client, Request, Response, DefaultTransport as HttpStream};
use hyper::header::Connection;
use hyper::{Decoder, Encoder, Next};

除某些注释外,文件的其余部分与存储库中examples/client.rs文件相同hyper

在编译时,出现以下错误:

src/main.rs:10:48: 10:78 error: unresolved import `hyper::client::DefaultTransport`. There is no `DefaultTransport` in `hyper::client` [E0432]
src/main.rs:10 use hyper::client::{Client, Request, Response, DefaultTransport as HttpStream};
                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:10:48: 10:78 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:12:13: 12:20 error: unresolved import `hyper::Decoder`. There is no `Decoder` in `hyper` [E0432]
src/main.rs:12 use hyper::{Decoder, Encoder, Next};
                           ^~~~~~~
src/main.rs:12:13: 12:20 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:12:22: 12:29 error: unresolved import `hyper::Encoder`. There is no `Encoder` in `hyper` [E0432]
src/main.rs:12 use hyper::{Decoder, Encoder, Next};
                                    ^~~~~~~
src/main.rs:12:22: 12:29 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:12:31: 12:35 error: unresolved import `hyper::Next`. There is no `Next` in `hyper` [E0432]
src/main.rs:12 use hyper::{Decoder, Encoder, Next};
                                             ^~~~
src/main.rs:12:31: 12:35 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:53:6: 53:40 error: trait `hyper::client::Handler` is not in scope [E0405]
src/main.rs:53 impl hyper::client::Handler<HttpStream> for Dump {
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:53:6: 53:40 help: run `rustc --explain E0405` to see a detailed explanation
src/main.rs:53:6: 53:40 help: you can to import it into scope: `use hyper::server::Handler;`.

如果可能导致此问题,请参阅以下内容Cargo.toml

name = "my_project"
version = "0.0.1"
authors = ["[email protected]"]

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

[[bin]]
name = "my_project"

某些导入实际上是有效的,因此,假设存储库中的示例是最新的,我真的不知道出了什么问题。板条箱的源文件看起来像它们都暴露了所涉及的类型,但是我对Rust还是很陌生,所以我可能会误读这些文件。

清算

您正在使用master分支中的不适用于0.9.6版本的示例您可以在分支上查看示例,0.9.6hyper直接从github进行货物使用,写在Cargo.toml

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章