[−][src]Trait endio::EWrite
Only necessary for custom (de-)serializations.
Interface for writing data with a specified endianness. Use this interface to make serializations automatically switch endianness without having to write the same code twice.
In theory this would be the only write trait and BE-/LEWrite would be aliases to the BE/LE type parameter variants, but for some reason that doesn't import methods in use
notation.
Examples
use endio::LEWrite; let mut writer = vec![]; writer.write(42u8); writer.write(true); writer.write(754187983u32); assert_eq!(writer, b"\x2a\x01\xcf\xfe\xf3\x2c");
Provided methods
fn write<S: Serialize<E, Self>>(&mut self, ser: S) -> Res<()>
Writes a Serialize
to the writer, in the writer's endianness.
What's actually written is up to the implementation of the Serialize
.
fn write_be<S: Serialize<BigEndian, Self>>(&mut self, ser: S) -> Res<()>
Writes in forced big endian.
fn write_le<S: Serialize<LittleEndian, Self>>(&mut self, ser: S) -> Res<()>
Writes in forced little endian.