#big #repr #mark #io #struct #data #declaratively

ioendian

Simple wrapper type to declaratively mark a struct as big-endian or little-endian. Useful for when doing #[repr(C)] transmutes from IO data.

4 releases

Uses old Rust 2015

0.1.4 Jul 19, 2017
0.1.2 Jul 13, 2017
0.1.1 Jul 13, 2017
0.1.0 Jul 13, 2017

#18 in #repr

MIT license

5KB
161 lines

IOEndian

A tiny library to declaratively define endianness in a portable way, for IO. Allows an easy .native() method to convert to native endianness.

Examples

struct SomeStruct {
    first: Big<u16>,
    second: Big<i32>,
}

let foo = SomeStruct {
    first: Big([2, 1]),
    second: Big([2, 1, 1, 1]),
};

assert_eq!(foo.first.native() + foo.second.native(), 513 + 33_620_225)

No runtime deps