Skip to main content

Utf16ReadExt

Trait Utf16ReadExt 

Source
pub trait Utf16ReadExt: ReadBytesExt {
    // Provided methods
    fn shorts<T: ByteOrder>(self) -> Shorts<T, Self> 
       where Self: Sized { ... }
    fn utf16_chars<T: ByteOrder>(self) -> Chars<T, Self> 
       where Self: Sized { ... }
    fn read_utf16_line<T: ByteOrder>(
        &mut self,
        buf: &mut String,
    ) -> Result<usize, Error> { ... }
    fn utf16_lines<T: ByteOrder>(self) -> Lines<T, Self> 
       where Self: Sized { ... }
}
Expand description

Extension to the Read trait

Provided Methods§

Source

fn shorts<T: ByteOrder>(self) -> Shorts<T, Self>
where Self: Sized,

Transforms this instance into an Iterator over its u16-units (shorts).

The returned type implements Iterator where the Item is Result<u16, R::Err>. The yielded item is Ok if a short was successfully read and Err otherwise. EOF is mapped to returning None from this iterator.

Source

fn utf16_chars<T: ByteOrder>(self) -> Chars<T, Self>
where Self: Sized,

Transforms this instance into an Iterator over chars from utf-16.

The returned type implements Iterator where the Item is Result<char, R::Err>.

Source

fn read_utf16_line<T: ByteOrder>( &mut self, buf: &mut String, ) -> Result<usize, Error>

Reads all chars (from utf16) until a newline is reached (U+000A) and appends them to the provided buffer.

Source

fn utf16_lines<T: ByteOrder>(self) -> Lines<T, Self>
where Self: Sized,

Returns an iterator over the lines of this reader.

Like the normal BufRead::lines, newlines characters aren’t included

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Read> Utf16ReadExt for T