Bytesize
Semantic wrapper for byte count representations
Install / Use
/learn @bytesize-rs/BytesizeREADME
ByteSize
<!-- prettier-ignore-start --> <!-- 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).
ByteSizetype which presents size units convertible to different size units.- Arithmetic operations for
ByteSize. FromStrimpl forByteSize, 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
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
