I'm updating code to the newest versions of hyper and futures, but everything I've tried misses implemented traits in some kind or another.
A not working example playground for this ...
extern crate futures; // 0.3.5 extern crate hyper; // 0.13.6 use futures::{future, FutureExt, StreamExt, TryFutureExt, TryStreamExt}; use hyper::body; fn get_body_as_vec<'a>(b: body::Body) -> future::BoxFuture<'a, Result<Vec<String>, hyper::Error>> { let f = b.and_then(|bytes| { let s = std::str::from_utf8(&bytes).expect("sends no utf-8"); let mut lines: Vec<String> = Vec::new(); for l in s.lines() { lines.push(l.to_string()); } future::ok(lines) }); Box::pin(f) } This produces the error:
error[E0277]: the trait bound `futures::stream::AndThen<hyper::Body, futures::future::Ready<std::result::Result<std::vec::Vec<std::string::String>, hyper::Error>>, [closure@src/lib.rs:8:24: 15:6]>: futures::Future` is not satisfied --> src/lib.rs:17:5 | 17 | Box::pin(f) | ^^^^^^^^^^^ the trait `futures::Future` is not implemented for `futures::stream::AndThen<hyper::Body, futures::future::Ready<std::result::Result<std::vec::Vec<std::string::String>, hyper::Error>>, [closure@src/lib.rs:8:24: 15:6]>` | = note: required for the cast to the object type `dyn futures::Future<Output = std::result::Result<std::vec::Vec<std::string::String>, hyper::Error>> + std::marker::Send` I'm unable to create a compatible future. Body is a stream and I can't find any "converter" function with the required traits implemented.
With hyper 0.12, I used concat2().
and_thenfromStreamExtover reference of aStream.TryStreamExt, it is ok, what i meant is this: play.rust-lang.org/…