pub struct LineReader<R> { /* private fields */ }Expand description
A zero-copy & optimized line reader.
This reader recognizes both LF & CRLF line terminators, but not single
CR.
Implementations§
Source§impl<R: Read> LineReader<R>
impl<R: Read> LineReader<R>
Sourcepub fn from_reader(inner: R) -> Self
pub fn from_reader(inner: R) -> Self
Create a new reader with default using the provided reader implementing
std::io::Read.
Avoid providing a buffered reader because buffering will be handled for
you by the LineReader.
Sourcepub fn with_capacity(capacity: usize, inner: R) -> Self
pub fn with_capacity(capacity: usize, inner: R) -> Self
Create a new reader with provided buffer capacity and using the provided
reader implementing std::io::Read.
Avoid providing a buffered reader because buffering will be handled for
you by the LineReader.
Sourcepub fn count_lines(&mut self) -> Result<u64>
pub fn count_lines(&mut self) -> Result<u64>
Consume the reader to count the number of lines as fast as possible.
Sourcepub fn read_line(&mut self) -> Result<Option<&[u8]>>
pub fn read_line(&mut self) -> Result<Option<&[u8]>>
Attempt to read the next line from underlying reader.
Will return None if the end of stream was reached.
Sourcepub fn into_bufreader(self) -> BufReader<R>
pub fn into_bufreader(self) -> BufReader<R>
Return the underlying BufReader.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Return the underlying reader.
BEWARE: Already buffered data will be lost!