Trait basic_text::BufReadText [−][src]
pub trait BufReadText: BufRead { 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>ⓘNotable traits for TextLines<B>
impl<B: BufReadText> Iterator for TextLines<B> type Item = Result<TextString>;
where
Self: Sized, { ... } fn text_lines_lossy(self) -> TextLinesLossy<Self>ⓘNotable traits for TextLinesLossy<B>
impl<B: BufReadText> Iterator for TextLinesLossy<B> type Item = Result<TextString>;
where
Self: Sized, { ... } }
Expand description
An extension trait for BufRead
which adds functions for reading
lines as TextString
s.
Provided methods
fn 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.
fn 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.
fn text_lines(self) -> TextLines<Self>ⓘNotable traits for TextLines<B>
impl<B: BufReadText> Iterator for TextLines<B> type Item = Result<TextString>;
where
Self: Sized,
fn text_lines(self) -> TextLines<Self>ⓘNotable traits for TextLines<B>
impl<B: BufReadText> Iterator for TextLines<B> type Item = Result<TextString>;
where
Self: Sized,
Returns an iterator over the lines of this reader, similar to
BufRead::lines
, but returning TextString
s.
fn text_lines_lossy(self) -> TextLinesLossy<Self>ⓘNotable traits for TextLinesLossy<B>
impl<B: BufReadText> Iterator for TextLinesLossy<B> type Item = Result<TextString>;
where
Self: Sized,
fn text_lines_lossy(self) -> TextLinesLossy<Self>ⓘNotable traits for TextLinesLossy<B>
impl<B: BufReadText> Iterator for TextLinesLossy<B> type Item = Result<TextString>;
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.