StringRead

Trait StringRead 

Source
pub trait StringRead: Sealed {
    // Required methods
    fn read_string_u16_le_len_utf8(&mut self) -> Result<String>;
    fn read_string_u16_be_len_utf8(&mut self) -> Result<String>;
    fn read_string_u32_le_len_utf8(&mut self) -> Result<String>;
    fn read_string_u32_be_len_utf8(&mut self) -> Result<String>;
    fn read_string_zero_terminated_utf8(&mut self) -> Result<String>;
    fn read_string_utf8(&mut self, size: usize) -> Result<String>;
    fn read_string_utf16_be(
        &mut self,
        size_in_characters: usize,
    ) -> Result<String>;
    fn read_string_utf16_le(
        &mut self,
        size_in_characters: usize,
    ) -> Result<String>;
    fn read_string_utf32_be(
        &mut self,
        size_in_characters: usize,
    ) -> Result<String>;
    fn read_string_utf32_le(
        &mut self,
        size_in_characters: usize,
    ) -> Result<String>;
    fn read_java_data_input_utf(&mut self) -> Result<String>;
}
Expand description

Trait that provides various methods to read strings. Automatically implemented for all implementations of io::Read. This trait is sealed and cannot be implemented manually.

Required Methods§

Source

fn read_string_u16_le_len_utf8(&mut self) -> Result<String>

Reads an u32 in little endian length prefix followed by that amount of bytes. The bytes are then parsed as utf-8.

Source

fn read_string_u16_be_len_utf8(&mut self) -> Result<String>

Reads an u32 in big endian length prefix followed by that amount of bytes. The bytes are then parsed as utf-8.

Source

fn read_string_u32_le_len_utf8(&mut self) -> Result<String>

Reads an u32 in little endian length prefix followed by that amount of bytes. The bytes are then parsed as utf-8.

Source

fn read_string_u32_be_len_utf8(&mut self) -> Result<String>

Reads an u32 in big endian length prefix followed by that amount of bytes. The bytes are then parsed as utf-8.

Source

fn read_string_zero_terminated_utf8(&mut self) -> Result<String>

Reads until zero byte and treats all bytes read as utf-8 string.

Source

fn read_string_utf8(&mut self, size: usize) -> Result<String>

Read given amount of bytes and treat them as UTF-8 string.

Source

fn read_string_utf16_be(&mut self, size_in_characters: usize) -> Result<String>

Read given amount of characters of an utf-16-be string.

Source

fn read_string_utf16_le(&mut self, size_in_characters: usize) -> Result<String>

Read given amount of characters of an utf-16-le string.

Source

fn read_string_utf32_be(&mut self, size_in_characters: usize) -> Result<String>

Read given amount of characters of an utf-32-be string.

Source

fn read_string_utf32_le(&mut self, size_in_characters: usize) -> Result<String>

Read given amount of characters of an utf-32-le string.

Source

fn read_java_data_input_utf(&mut self) -> Result<String>

Reads a string that was produced by a java program using the java.io.DataOutput#writeUTF facility. In general, it reads an u16 in big endian to indicate how many further bytes are needed. It then parses the data to create an utf-16 u16 array. Each u16 consists of 1, 2 or 3 bytes encoded in a custom java specific encoding. After parsing all the data the u16 array contains utf-16 data that will be turned into a String using String::from_utf16.

Implementors§

Source§

impl<T> StringRead for T
where T: Read,