Module csx64::common::serialization[][src]

Utilities for representing values in cross-platform binary.

It is intended that all implementors use little-endian byte ordering for multi-byte values, but this is not strictly required.

BinaryRead and BinaryWrite are the two main features of this module. They are implemented for all integer primitives with the notable exception of u8. This is because stable rust does not currently support specialization, meaning the blanket implementations for [T] and Vec<T> would otherwise conflict with the performance-based implementations for [u8] and Vec<u8>. To support the same interface (but not the same trait), u8 implements TrivialBinaryRead and TrivialBinaryWrite. This is typically not an issue, as arrays are the only common container for bytes.

Example

let mut f = vec![];
"hello world".bin_write(&mut f).unwrap();
assert_eq!(String::bin_read(&mut f.as_slice()).unwrap(), "hello world");

Traits

BinaryRead

Denotes that a type can be decoded from cross-platform binary.

BinaryWrite

Denotes that a type can be encoded as cross-platform binary.

TrivialBinaryRead

Denotes that a type can be trivially decoded from cross-platform binary.

TrivialBinaryWrite

Denotes that a type can be trivially encoded as cross-platform binary.