Documentation
  • Coverage
  • 0%
    0 out of 1 items documented0 out of 0 items with examples
  • Size
  • Source code size: 13.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 101.67 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 19s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tryor

box-convert

English | 简体中文

box-convert provides type conversion utilities, currently featuring a Bytesize type that parses human-readable byte size strings (e.g., "1K2M3B") and formats byte counts back to readable strings.

Features

  • Bytesize — human-readable byte size parsing and formatting
  • Supports K/M/G suffixes (e.g., "1K", "2M", "3G")
  • Combined format parsing (e.g., "1K2M3B")
  • Serde support for JSON serialization
  • From<usize> and From<&str> conversions

Cargo Feature Flags

Feature Description Default
bytesize Enable the Bytesize type for human-readable byte parsing no

Basic Usage

use convert::Bytesize;

let b = Bytesize::from("1K");
assert_eq!(*b, 1024);

let b = Bytesize::from(2048usize);
assert_eq!(b.string(), "2K");

Tests

cargo test -p box-convert --features "bytesize"

8 tests covering From implementations, string formatting, serde roundtrip, and edge cases.

License

Licensed under either of Apache License 2.0 or MIT license at your option.