intpack 0.1.0

intpack is a collection of functions for packing/unpacking unsigned integers into other unsigned integers of different sizes. For example, packing 4 u8's into a u32.
Documentation
  • Coverage
  • 47.83%
    11 out of 23 items documented0 out of 20 items with examples
  • Size
  • Source code size: 7.25 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 350.51 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Will-Banksy/intpack
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Will-Banksy

intpack

intpack is a collection of functions for packing/unpacking unsigned integers into other unsigned integers of different sizes. For example, packing 4 u8's into a u32.

!! The functions haven't been fully tested (but they should work) !!

Usage

Packing 4 u8's into a u32 using the u8_to_u32 function:

use intpack::pack;

let result = pack::u8_to_u32(&[0xff, 0x00, 0xff, 0x00]);
// Returns 0xff00ff00

And unpacking that u32:

use intpack::unpack;

let result = unpack::u32_to_u8(0xff00ff00);
// Returns [0xff, 0x00, 0xff, 0x00]

It's important to note, when packing, the least significant byte in the input slice (at index 0) becomes the most significant byte in the output value.

When unpacking, the most significant byte in the input value becomes the least significant byte in the output array (at index 0).