swapbytes 0.1.0

Crate for swapping the endianess of structures
Documentation

Swapbytes

License Cargo Version Cargo Downloads

Rust library for swapping the endianess of a structure using a derive macro

Cargo

Using swapbytes with cargo

[dependencies]
swapbytes = "0.1"

or

cargo add swapbytes
use swapbytes::SwapBytes;

#[derive(SwapBytes)]
pub struct Test {
    pub a: u32,
    pub b: u32,
    /// Skip this field
    #[sb(skip)]
    pub b: String,
}

let mut value: Test = Test { a: 1, b: 4 };
value.swap_bytes_mut();