Has anyone developed magic required to have an unbuffered (or very-tiny-buffered) futures::Stream that can be written to using io::Write?
I have a complex function that I can't change, which writes its output to io::Write, and I'd like to send this output, with as little buffering as possible, to a framework that expects a futures::Stream.
io::Write is blocking push-based, and the stream is async poll-based, so I presume the adapter would be non-trivial and would have to do something clever. Has anyone worked it out yet?
This turns out to be tricky, because Stream.poll() can't block on recv(), and can't ask try_recv() for a callback when it becomes ready, so there's nothing to call task.notify().
OTOH if I use futures::mpsc, then polling is easy, but pushing is hard, because sending is a Future, so it needs a reactor for polling.
Yes, I run it on another thread already. But I still need to deliver the results in a streaming fashion, so waiting for the end of the blocking task is not an option.