I would like to read data from the TcpStream
until I encounter a '\0'.
The issue is that tokio::io::read_until
needs the stream to be BufRead
.
fn poll(&mut self) -> Poll<(), Self::Error> {
match self.listener.poll_accept()? {
Async::Ready((stream, _addr)) => {
let task = tokio::io::read_until(stream, 0, vec![0u8; buffer])
.map_err(|_| ...)
.map(|_| ...);
tokio::spawn(task);
}
Async::NotReady => return Ok(Async::NotReady),
}
}
How can I read data from the TcpStream
this way?