Trait bytelines::ByteLinesReader
source · pub trait ByteLinesReader<'a, B>where
B: BufRead,{
fn byte_lines(self) -> ByteLines<'a, B> ⓘ;
unsafe fn ref_byte_lines(self) -> RefByteLines<'a, B> ⓘ;
}
Expand description
Represents anything which can provide iterators of byte lines.
Required Methods§
sourcefn byte_lines(self) -> ByteLines<'a, B> ⓘ
fn byte_lines(self) -> ByteLines<'a, B> ⓘ
Returns an iterator over the lines of this reader (as Vec<u8>
).
Just like the equivalent in the standard library, the iterator returned
from this function will yield instances of io::Result<String>
. Each
string returned will not have a newline byte (the 0xA byte) or CRLF
(0xD, 0xA bytes) at the end.
sourceunsafe fn ref_byte_lines(self) -> RefByteLines<'a, B> ⓘ
unsafe fn ref_byte_lines(self) -> RefByteLines<'a, B> ⓘ
Returns an iterator over the lines of this reader (as &[u8]
).
This method operates in the same way as byte_lines,
except that the iterated values are references to the internal byte buffer.
Due to this, you can only safely hold a single line at any given time, and
as such this method is marked as unsafe
. If you’re using usual loop syntax
of for $x in $y
your code will not come across this unsafe contract.
When performance is important, this method should be used rather than
byte_lines as there is only a single buffer
allocation (disregarding any potential resizing that may be required),
whereas byte_lines will allocate a Vec<u8>
for
each input line and provide ownership.
Implementors§
impl<'a, B> ByteLinesReader<'a, B> for Bwhere
B: BufRead,
Blanket implementation for all BufRead
.