(Using tokio head from the git repo)
I have read half of a tokio TcpStream/TlsStream and I want to use it in a
select! block which is in a
loop. The problem is after every read the read buffer should be reset, but
read() can't do it (because if it does I won't be able to read the contents of the buffer after it returns), and I can't do it either because the fused reader has a mutable reference to the read buffer so I have to drop the it first (which I can't, otherwise I lose the is_terminated info).
I want to
- Move the
fuse()part out of the loop
- But still be able to reset
read_bufafter every successful read.
Anyone know a way to do this?
Someone on the tokio gitter channel suggested fusing the read half first, and then calling
read(&mut read_buf) on it, but
futures_util::io::ReadHalf doesn't have a
FutureExt impl so that doesn't work.