I don't yet have an intuitive sense of rust error checking stages beyond knowing that I won't get borrow checker errors until I've fixed everything else.
1
Streams and Futures are distinct things and trying to pass one of them off as the other will blow up. There's the Stream::into_future adapter to turn a Stream into a Future resolving to the next item.
1
1
If you pastebin the error message I can try to make sense of it.
1
What I was trying to do was pass the stream off to the Core or Handle to run (pump?) it to completion. I'd thought I'd done that before, but in hindsight I'd only passed the result of stream.join(future) to one elsewhere in a way that worked.
1
Ah. Pumping a Stream to the end is what `Stream::for_each` is for.
1
Yeah, I was just rereading that; I hadn't realized that Stream::for_each produced a future rather than a stream, but I realized it just before seeing your response.
1
1
rufflewind.com/img/rust-futu… is really helpful for Future but I don't know of an equivalent for Stream. Maybe I should just write it myself.
1
Curious if pastebin.mozilla.org/9081121 leads to immediate advice, though. (I'm confused, since the inner type is std::result::Result<(), std::io::Error> so I'd think the outer Error type would be std::io::Error and not ().)
1
Handle::spawn needs a future with Error=() because it doesn't know what to do with the error.
2
So you need to take your future and map_err it to dispose of the error somehow.
1
Replying to @khuey_
Ah, makes sense that Handle::spawn needs no error and that's different from Core::run. I guess I had the wrong docs for Handle since I was confused by looking at: docs.rs/tokio/0.1/tokio/reac… when I should have been looking at: docs.rs/tokio-core/0.1/tokio…

Mar 28, 2018 · 7:47 PM UTC

1
Replying to @davidbaron
I don't even know what the first one is :P