I have a function that retures stream::iter_ok::<Response<String>>, io::Error>, what should be the function signature?
Hi there, I have a function that retures stream::iter_ok::<Response<String>>, io::Error>, what should be the function signature? I tried dyn futures::stream::Stream<Item = Response<String>, Error = io::Error> + 'static but I got error
fn handle_register(req: Request<()>) -> dyn futures::stream::Stream<Item = Response<String>, Error = io::Error> + 'static {
let mut res = Response::builder();
res.header("xhead", req.headers().get("xhead").unwrap().clone());
let res = res.body("".to_string()).unwrap();
stream::iter_ok::<_, io::Error>(vec![res])
}
fn handle_register(req: Request<()>) -> dyn futures::stream::Stream<Item = Response<String>, Error = io::Error> + 'static {
let mut res = Response::builder();
res.header("xhead", req.headers().get("xhead").unwrap().clone());
let res = res.body("".to_string()).unwrap();
stream::iter_ok::<_, io::Error>(vec![res])
}
No any search results
You already invited:
1 Answers
Sharun - be myself
Upvotes from:
dyn only works like &dyn Stream or Box<dyn Stream>... you could Box<dyn Stream<Item = ...etc...>> if you wanted