Trait infinite_rs::common::extensions::BufReaderExt

source ·
pub trait BufReaderExt: BufRead {
    // Provided methods
    fn read_cstring(&mut self) -> Result<String> { ... }
    fn read_fixed_string(&mut self, length: usize) -> Result<String> { ... }
}
Expand description

Extension trait for BufReader to add custom reading methods.

Provided Methods§

source

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

Reads a UTF-8 encoded C-style string from the reader until a null terminator (0x00) is encountered.

§Returns

Returns an io::Result<String> containing the read string.

§Errors

This function will return an error if:

  • There’s an I/O error while reading from the reader.
  • The read bytes are not valid UTF-8.
source

fn read_fixed_string(&mut self, length: usize) -> Result<String>

Reads a fixed-length UTF-8 encoded string from the reader.

This function reads exactly length bytes, ignores unknown UTF-8 encodings, and trims any null bytes found at the end of the string.

§Arguments
  • length - The number of bytes to read.
§Returns

Returns an io::Result<String> containing the read string.

§Errors

Returns Ok(()) if the read operation is successful, or an Err containing the I/O error if any reading operation fails.

Implementations on Foreign Types§

source§

impl<R: Read> BufReaderExt for BufReader<R>

Implementors§