pub trait WriteEndian<T: ?Sized> {
// Required methods
fn write_as_little_endian(&mut self, value: &T) -> Result<()>;
fn write_as_big_endian(&mut self, value: &T) -> Result<()>;
// Provided method
fn write_as_native_endian(&mut self, value: &T) -> Result<()> { ... }
}
Expand description
A std::io::Write
output stream which supports writing any primitive values as bytes.
Will encode the values to be either little endian or big endian, as desired.
This extension trait is implemented for all Write
types.
Add use lebe::io::WriteEndian;
to your code
to automatically unlock this functionality for all types that implement Write
.
Required Methods§
sourcefn write_as_little_endian(&mut self, value: &T) -> Result<()>
fn write_as_little_endian(&mut self, value: &T) -> Result<()>
Write the byte value of the specified reference, converting it to little endianness
sourcefn write_as_big_endian(&mut self, value: &T) -> Result<()>
fn write_as_big_endian(&mut self, value: &T) -> Result<()>
Write the byte value of the specified reference, converting it to big endianness
Provided Methods§
sourcefn write_as_native_endian(&mut self, value: &T) -> Result<()>
fn write_as_native_endian(&mut self, value: &T) -> Result<()>
Write the byte value of the specified reference, not converting it