MCPcopy Index your code
hub / github.com/bytesize-rs/bytesize

github.com/bytesize-rs/bytesize @bytesize-v2.4.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release bytesize-v2.4.2 ↗ · + Follow
123 symbols 230 edges 9 files 17 documented · 14%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ByteSize

crates.io Documentation Version Apache 2.0 licensed

Dependency Status Download

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);

Core symbols most depended-on inside this repo

assert_to_string
called by 18
src/display.rs
factor
called by 9
src/parse.rs
mib
called by 8
src/lib.rs
assert_display
called by 8
src/lib.rs
kib
called by 5
src/lib.rs
mb
called by 5
src/lib.rs
gb
called by 5
src/lib.rs
kb
called by 4
src/lib.rs

Shape

Method 62
Function 52
Class 7
Enum 2

Languages

Rust100%

Modules by API surface

src/lib.rs58 symbols
src/display.rs22 symbols
src/parse.rs16 symbols
src/serde.rs10 symbols
benches/display.rs8 symbols
ensure-no-std/src/main.rs5 symbols
src/arbitrary.rs2 symbols
examples/ls.rs1 symbols
ensure-no-std/src/compat_test.rs1 symbols

For agents

$ claude mcp add bytesize \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact