pub trait LengthDelimitedReadExt {
// Required method
fn read_delimited(&mut self) -> Result<Vec<u8>>;
// Provided method
fn read_str_delimited(&mut self) -> Result<String> { ... }
}Expand description
An extension on top of io::Read that reads data with length delimiters that was written using LengthDelimitedWriteExt. This is particularly useful for adding extra data before or after data structures written by FSW games.
The specific format used by this trait is a little-endian four-byte header indicating the length of the data in bytes, followed by the data itself.
Required Methods§
Sourcefn read_delimited(&mut self) -> Result<Vec<u8>>
fn read_delimited(&mut self) -> Result<Vec<u8>>
Reads a length-delimited amount of data from the underlying reader into a newly-allocated Vec.
This is the dual of [LengthDelimitedWriteExt.write_delimited].
Unlike [io::Read.read], this will return an error result if there’s not enough data available to read the full result.
Provided Methods§
Sourcefn read_str_delimited(&mut self) -> Result<String>
fn read_str_delimited(&mut self) -> Result<String>
Reads a length-delimited amount of data from the underlying reader into a newly-allocated String.
This is the dual of [LengthDelimitedWriteExt.write_str_delimited].
Unlike [io::Read.read], this will return an error result if there’s not enough data available to read the full result. This will also return an error if the data isn’t valid UTF-8.