$ byte-unit

v5.2.3

A library for interacting with units of bytes.

Downloads: 33.8M
Recent: 5.2M
Versions: 59
Updated: June 16, 2026

Latest Update Summary

Crate

Name: byte-unit New version: 5.2.0 Release date: 2025-11-23T14:00:00.482050Z

Crate readme

Short description A library for interaction with units of bytes.

Long description Byte Unit provides data types and functionality for storing and converting between various byte sizes. With default support for u64, it can represent sizes up to E, or up to Y if the u128 feature is enabled. The library includes units for bits and bytes, methods for arithmetic operations, and formatted output. It supports optional features like serde for serialization and no_std for compatibility with environments lacking standard library support.

Features • no_std compatibility • serde support • schemars support • rocket support • bit feature for bit representation

Code Examples Add to Cargo.toml

 [dependencies.byte-unit]
version = "*"
default-features = false
features = ["byte"]

Creating Byte from u64

 use byte_unit::Byte;

assert_eq!(15000, Byte::from_u64(15000).as_u64());

Parsing string to Byte

 use byte_unit::Byte;

assert_eq!(50840000, Byte::parse_str("50.84 MB", true).unwrap().as_u64());

Arithmetic operations with Byte

 use byte_unit::Byte;

let a = Byte::from_u64(15500);
let b = Byte::from_u64(500);

assert_eq!(16000, a.add(b).unwrap().as_u64());

Getting AdjustedByte Unit

 use byte_unit::{Byte, Unit};

let byte = Byte::parse_str("123KiB", true).unwrap();

let adjusted_byte = byte.get_adjusted_unit(Unit::KB);

assert_eq!("125.952 KB", adjusted_byte.to_string());

Linkshttps://crates.io/crates/byte-unithttps://docs.rs/byte-unit

Release info

Release version: N/A

Release description N/A

Code Examples N/A

Patch update: 5.2.0 → 5.2.3

$ DOWNLOADS TREND

18.9M33.8M

$ VERSION HISTORY

v5.2.3June 16, 2026
v5.2.0November 23, 2025
v5.1.6November 2, 2024

$ LINKS

$ INSTALL

cargo add byte-unit

Or add to Cargo.toml: byte-unit = "5.2.3"