https://stackoverflow.com/q/43419974/155423
I'd probably do
use futures::{Future, Stream}; // 0.1.25
use hyper; // 0.12.14
use std::str;
type Error = Box<dyn std::error::Error>;
fn example(body: hyper::Body) -> impl Future<Item = String, Error = Error> {
body.map_err(Error::from)
.concat2()
.and_then(|c| {
str::from_utf8(&c).map(str::to_owned).map_err(Error::from)
})
}