Trait utf8_io::ReadStr

source ·
pub trait ReadStr: Read {
    // Required method
    fn read_str(&mut self, buf: &mut str) -> Result<usize>;

    // Provided method
    fn read_exact_str(&mut self, buf: &mut str) -> Result<()> { ... }
}
Expand description

Extend the Read trait with read_str, a method for reading UTF-8 data.

Required Methods§

source

fn read_str(&mut self, buf: &mut str) -> Result<usize>

Like read but produces the result in a str. Be sure to check the size field of the return value to see how many bytes were written.

buf must be at least 4 bytes long, so that any valid UTF-8 codepoint can be read.

Provided Methods§

source

fn read_exact_str(&mut self, buf: &mut str) -> Result<()>

Like read_exact but produces the result in a str.

Implementors§

source§

impl<Inner: Read> ReadStr for Utf8Reader<Inner>

source§

impl<Inner: HalfDuplex> ReadStr for Utf8Duplexer<Inner>