SkillAgentSearch skills...

Bytesize

Semantic wrapper for byte count representations

Install / Use

/learn @bytesize-rs/Bytesize
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

ByteSize

<!-- prettier-ignore-start -->

crates.io Documentation Version Apache 2.0 licensed <br /> Dependency Status Download

<!-- prettier-ignore-end --> <!-- cargo-rdme start -->

ByteSize is a semantic wrapper for byte count representations.

Features:

  • Pre-defined constants for various size units (e.g., B, Kb, Kib, Mb, Mib, Gb, Gib, ... PB).
  • ByteSize type which presents size units convertible to different size units.
  • Arithmetic operations for ByteSize.
  • FromStr impl for ByteSize, allowing for parsing string size representations like "1.5KiB" and "521TiB".
  • Serde support for binary and human-readable deserializers like JSON.

Examples

Construction using SI or IEC helpers.

use bytesize::ByteSize;

assert!(ByteSize::kib(4) > ByteSize::kb(4));

Display as human-readable string.

use bytesize::ByteSize;

assert_eq!("518.0 GiB", ByteSize::gib(518).display().iec().to_string());
assert_eq!("556.2 GB", ByteSize::gib(518).display().si().to_string());
assert_eq!("518.0G", ByteSize::gib(518).display().iec_short().to_string());

Arithmetic operations are supported.

use bytesize::ByteSize;

let plus = ByteSize::mb(1) + ByteSize::kb(100);
println!("{plus}");

let minus = ByteSize::tb(1) - ByteSize::gb(4);
assert_eq!(ByteSize::gb(996), minus);
<!-- cargo-rdme end -->

Related Skills

View on GitHub
GitHub Stars156
CategoryDevelopment
Updated14h ago
Forks41

Languages

Rust

Security Score

95/100

Audited on Apr 1, 2026

No findings