byte-repr 0.2.0

A utility to inspect binary, little-endian, and big-endian memory representations of numbers.
Documentation
  • Coverage
  • 80%
    4 out of 5 items documented2 out of 4 items with examples
  • Size
  • Source code size: 31.13 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.22 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • rust-dev-pan/byte-repr
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • himangshu-blockchain

๐ŸŽ“ Rust Crate Experiment | byte-repr

Crates.io Docs.rs Build Status MIT/Apache-2.0 licensed Downloads MSRV

A lightweight utility for inspecting and learning about memory representation of integer types in Rust.


๐Ÿ“˜ Overview

byte-repr is a simple, extensible Rust crate to help visualize how numeric types are represented in memory. It supports both little-endian and big-endian byte formats, binary representation, and hex with zero-padding.

Useful for:

  • ๐Ÿง  Learning & teaching endianness and bit-level encoding
  • ๐Ÿ› ๏ธ Debugging binary data
  • ๐Ÿงฌ Understanding low-level memory layouts in Rust

โœจ Features

  • ๐Ÿ“ฆ Print values in:
    • Binary format (grouped bits)
    • Little-endian byte array
    • Big-endian byte array
    • Hexadecimal representation (zero-padded)
  • ๐Ÿงฉ Macro-based extensibility for custom numeric types
  • ๐Ÿงช Tested against all supported integer types
  • ๐ŸŽจ Color-coded output for clarity

๐Ÿš€ Usage

Add this to your Cargo.toml:

[dependencies]
byte-repr = "0.1.0" # update after publishing

Then use in your code:

use byte_repr::represent;

fn main() {
    let x = 42u16;
    represent(&x);
}

Example Output:

example output

๐Ÿ”ง Supported Types

Currently supports:

  • i8
  • u16
  • u32
  • u64
  • u128
  • usize

โœ… impl_byterep! macro makes it easy to extend support to custom numeric types.

โš ๏ธ Limitations

  • โŒ Not yet #![no_std] compatible

  • โŒ No support for wasm32 (WebAssembly) targets

  • ๐Ÿ“Œ Relies on println! for display, which isn't available in no_std or wasm

โœ… These will be addressed in upcoming versions. Stay tuned!

๐Ÿงช Tests

Includes integration tests for:

  • Endianness checks
  • Binary and hex formatting
  • Trait conformance per type
  • Visual rendering test (smoke check)

๐Ÿ“ฆ License

See the LICENSE-MIT file for details.

๐Ÿ“‘ Changelog

See CHANGELOG.md for a history of changes.