Любой совет по использованию Hyper в Rust

Я искал любые рабочие примеры и хорошую документацию для Hyper Crate в ржавчине и наткнулся на пример здесь. Однако, когда я запускаю этот пример, я получаю несколько ошибок.

error[E0061]: this function takes 1 parameter but 0 parameters were supplied
 --> src/main.rs:8:18
  |
8 |     let client = Client::new();
  |                  ^^^^^^^^^^^^^ expected 1 parameter

error[E0308]: mismatched types
  --> src/main.rs:11:26
   |
11 |     let res = client.get("https://www.reddit.com/r/programming/.rss")
   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `hyper::Uri`, found reference
   |
   = note: expected type `hyper::Uri`
              found type `&'static str`

error[E0599]: no method named `send` found for type `hyper::client::FutureResponse` in the current scope
  --> src/main.rs:12:22
   |
12 |                     .send()
   |                      ^^^^

error: aborting due to 3 previous errors

Кто-нибудь знает, что я делаю неправильно? Я действительно изо всех сил пытаюсь понять, как сделать функциональный код ржавчины, когда код примера не работает для меня.

Похоже, что этот пример устарел, поэтому возьмите пример из гипердокументации и добавьте fn main(), чтобы он мог работать:

extern crate futures;
extern crate hyper;
extern crate tokio_core;

use std::io::{self, Write};
use futures::{Future, Stream};
use hyper::Client;
use tokio_core::reactor::Core;

fn main(){
    let mut core = Core::new()?;
    let client = Client::new(&core.handle());

    let uri = "http://httpbin.org/ip".parse()?;
    let work = client.get(uri).and_then(|res| {
        println!("Response: {}", res.status());

        res.body().for_each(|chunk| {
            io::stdout()
                .write_all(&chunk)
                .map_err(From::from)
        })
    });
    core.run(work)?;
}

Который терпит неудачу с ошибками:

error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
  --> src/main.rs:11:20
   |
11 |     let mut core = Core::new()?;
   |                    ------------
   |                    |
   |                    the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`)
   |                    in this macro invocation
   |
   = help: the trait `std::ops::Try` is not implemented for `()`
   = note: required by `std::ops::Try::from_error`

error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
  --> src/main.rs:14:15
   |
14 |     let uri = "http://httpbin.org/ip".parse()?;
   |               --------------------------------
   |               |
   |               the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`)
   |               in this macro invocation
   |
   = help: the trait `std::ops::Try` is not implemented for `()`
   = note: required by `std::ops::Try::from_error`

error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
  --> src/main.rs:24:5
   |
24 |     core.run(work)?;
   |     ---------------
   |     |
   |     the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`)
   |     in this macro invocation
   |
   = help: the trait `std::ops::Try` is not implemented for `()`
   = note: required by `std::ops::Try::from_error`

error: aborting due to 3 previous errors

Заранее спасибо.


person crazy_greg    schedule 03.11.2017    source источник
comment
Похоже, это может быть для старой версии. Пробовали ли вы читать официальную документацию?   -  person interjay    schedule 03.11.2017
comment
Да, я пытался смотреть на это. Простой пример get также не работает. Вот почему я обратился к stackoverflow...   -  person crazy_greg    schedule 03.11.2017