swapbytes-derive

Crates.ioswapbytes-derive
lib.rsswapbytes-derive
version0.2.0
sourcesrc
created_at2023-11-20 04:40:51.240341
updated_at2023-11-21 04:41:43.940934
descriptionDerive macros for working with the swapbytes crate
homepage
repositoryhttps://github.com/jacobtread/bytereorder
max_upload_size
id1041710
size4,772
Jacob (jacobtread)

documentation

README

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.2"

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();


/* Enum must implement Clone, Copy */
#[derive(SwapBytes, Clone, Copy)]
#[repr(u32)] /* Only number repr types are supported */
pub enum ReprEnum {
    A = 1,
    B = 2
}

Commit count: 0

cargo fmt