Trait basic_text::BufReadText
source · pub trait BufReadText: BufRead {
// Provided methods
fn read_text_line(&mut self, buf: &mut TextString) -> Result<usize> { ... }
fn read_text_line_lossy(&mut self, buf: &mut TextString) -> Result<usize> { ... }
fn text_lines(self) -> TextLines<Self> ⓘ
where Self: Sized { ... }
fn text_lines_lossy(self) -> TextLinesLossy<Self> ⓘ
where Self: Sized { ... }
}
Expand description
An extension trait for BufRead
which adds functions for reading
lines as TextString
s.
Provided Methods§
sourcefn read_text_line(&mut self, buf: &mut TextString) -> Result<usize>
fn read_text_line(&mut self, buf: &mut TextString) -> Result<usize>
Read all bytes until a newline (the 0xA
byte) is reached, and append
them to the provided buffer, similar to BufRead::read_line
, but
require the input to contain valid Basic Text, and require each line
to be a valid Basic Text string.
Basic Text streams always end with a newline, so the returned string will always have a trailing newline.
This function is blocking and should be used carefully: it is possible for an attacker to continuously send bytes without ever sending a newline or ending the stream.
sourcefn read_text_line_lossy(&mut self, buf: &mut TextString) -> Result<usize>
fn read_text_line_lossy(&mut self, buf: &mut TextString) -> Result<usize>
Read all bytes until a newline (the 0xA
byte) is reached, and append
them to the provided buffer, similar to BufRead::read_line
,
converting the input to Basic Text using lossy conversions if needed.
Basic Text streams always end with a newline, so the returned string will always have a trailing newline.
This function is blocking and should be used carefully: it is possible for an attacker to continuously send bytes without ever sending a newline or ending the stream.
sourcefn text_lines(self) -> TextLines<Self> ⓘwhere
Self: Sized,
fn text_lines(self) -> TextLines<Self> ⓘwhere Self: Sized,
Returns an iterator over the lines of this reader, similar to
BufRead::lines
, but returning TextString
s.
sourcefn text_lines_lossy(self) -> TextLinesLossy<Self> ⓘwhere
Self: Sized,
fn text_lines_lossy(self) -> TextLinesLossy<Self> ⓘwhere Self: Sized,
Returns an iterator over the lines of this reader, similar to
BufRead::lines
, but returning TextString
s, converting the
input to Basic Text using lossy conversions if needed.