LengthDelimitedWriteExt

Trait LengthDelimitedWriteExt 

Source
pub trait LengthDelimitedWriteExt {
    // Required method
    fn write_delimited(&mut self, data: &[u8]) -> Result<usize>;

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

An extension on top of io::Write that writes data with length delimiters so that it can be read back using LengthDelimitedReadExt. 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§

Source

fn write_delimited(&mut self, data: &[u8]) -> Result<usize>

Writes data to the underlying writer with a length delimiter.

This is the dual of [LengthDelimitedReadExt.read_delimited].

Provided Methods§

Source

fn write_str_delimited(&mut self, text: &str) -> Result<usize>

Writes text to the underlying writer as UTF-8 with a length delimiter.

This is the dual of [LengthDelimitedReadExt.read_str_delimited].

Implementors§