Hello, I try to create a example with tokio-zmq and I have problem with response annotation
This is my function
type Sink = (Map<SplitStream<MultipartSinkStream<Rep>>, Fn() -> Multipart>, SplitSink<MultipartSinkStream<Rep>>);
fn run_client(ctx: Arc<zmq::Context>, addr: &str) -> impl Future<Item = Sink, Error = Error> + Send {
let client = Rep::builder(ctx).connect(addr).build();
client.and_then(|rep| {
let (sink, stream) = rep.sink_stream(25).split();
stream
.map(|multipart|{
for msg in &multipart {
if let Some(msg) = msg.as_str() {
println!("{:?}", msg);
}
}
rep.send(multipart).and_then(|item| {
Ok(item)
});
multipart
})
.forward(sink)
})
}
The error show this:
error[E0271]: type mismatch resolving `<futures::AndThen<std::boxed::Box<dyn futures::Future<Item=tokio_zmq::Rep, Error=tokio_zmq::Error> + std::marker::Send>, std::boxed::Box<futures::stream::Forward<futures::stream::Map<futures::stream::SplitStream<tokio_zmq::async_types::MultipartSinkStream<tokio_zmq::Rep>>, [closure@src/main.rs:41:18: 53:14 rep:_]>, futures::stream::SplitSink<tokio_zmq::async_types::MultipartSinkStream<tokio_zmq::Rep>>>>, [closure@src/main.rs:37:21: 55:6]> as futures::Future>::Item == (futures::stream::Map<futures::stream::SplitStream<tokio_zmq::async_types::MultipartSinkStream<tokio_zmq::Rep>>, std::boxed::Box<(dyn std::ops::Fn() -> tokio_zmq::Multipart + 'static)>>, futures::stream::SplitSink<tokio_zmq::async_types::MultipartSinkStream<tokio_zmq::Rep>>)`
--> src/main.rs:34:54
|
34 | fn run_client(ctx: Arc<zmq::Context>, addr: &str) -> impl Future<Item = Sink, Error = Error> + Send {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected closure, found struct `std::boxed::Box`
|
= note: expected type `(futures::stream::Map<futures::stream::SplitStream<tokio_zmq::async_types::MultipartSinkStream<tokio_zmq::Rep>>, [closure@src/main.rs:41:18: 53:14 rep:_]>, futures::stream::SplitSink<tokio_zmq::async_types::MultipartSinkStream<tokio_zmq::Rep>>)`
found type `(futures::stream::Map<futures::stream::SplitStream<tokio_zmq::async_types::MultipartSinkStream<tokio_zmq::Rep>>, std::boxed::Box<(dyn std::ops::Fn() -> tokio_zmq::Multipart + 'static)>>, futures::stream::SplitSink<tokio_zmq::async_types::MultipartSinkStream<tokio_zmq::Rep>>)`
= note: the return type of a function must have a statically known size
error: aborting due to previous error
For more information about this error, try `rustc --explain E0271`.
error: Could not compile `zeromq_client`.
Any suggestion?