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 TextStrings.

Provided Methods§

source

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.

source

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.

source

fn text_lines(self) -> TextLines<Self>
where Self: Sized,

Returns an iterator over the lines of this reader, similar to BufRead::lines, but returning TextStrings.

source

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 TextStrings, converting the input to Basic Text using lossy conversions if needed.

Implementors§