swapbytes 0.2.1

Crate for swapping the endianess of structures
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 8.05 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.26 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jacobtread

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
}