#byte #endian #little-endian #big-endian #binary

no-std bitconv

A simple, zero-dependency, no_std compatible Rust equivalent to the C# BitConverter class

5 releases

0.1.4 Mar 8, 2021
0.1.3 Jan 27, 2021
0.1.2 Jan 27, 2021
0.1.1 Jan 27, 2021
0.1.0 Jan 27, 2021

#300 in No standard library

MIT license

19KB
315 lines

Current Crates.io Version docs-rs

bitconv

A simple, zero-dependency, no_std compatible Rust equivalent to the C# BitConverter class.

To add to your Cargo.toml:

bitconv = "0.1.4"

Example

use bitconv::{endian::{Big, Little, Native}, to_uint32};

fn main() {
    let buffer = [15, 0, 0, 0, 0, 16, 0, 255, 3, 0, 0, 202, 19];
    assert_eq!(261888, to_uint32::<Little>(&buffer, 6));
    assert_eq!(261888, to_uint32::<Native>(&buffer, 6));
    assert_eq!(16712448, to_uint32::<Big>(&buffer, 6));
}

No runtime deps