I'm writing a parser that consumes data from a regular file, a named pipe (mkfifo), or StdIn.
When using BufRead::read_line on a normal file, Ok(0) will tell me the file is closed. However the named pipe (and presumably StdIn) also returns Ok(0) when the pipe is empty.
When I delete the named pipe, it continues returning Ok(0).
Is there a way around this? Or do I need to implement a custom BufRead that does what I need?
BufRead::read_line should block until it encounters a newline or EOF. Only if the stream has reached EOF, Ok(0) is returned (an empty line would still return Ok(1), adding \n to the buffer). For Stdin that's the case. Are you sure calling read_line on your named pipe returns Ok(0) if the pipe is not yet closed? What crate are you using for the pipe?