#byte #units #conversion #convert #data-size

byte_converter

A Rust library for converting bytes to various units (KB, MB, GB, etc.)

3 releases

new 0.1.2 Oct 31, 2024
0.1.1 Oct 29, 2024
0.1.0 Oct 29, 2024

#719 in Data structures

Download history 164/week @ 2024-10-24

164 downloads per month

MIT license

5KB

byte_converter

byte_converter is a Rust library for converting between bytes, kilobytes, and megabytes.

Installation

Add byte_converter to your Cargo.toml: [dependencies] byte_converter = "0.1.0"

Usage

Then, you can use the conversion functions:

use byte_converter::{bytes_to_kb, kb_to_mb};

fn main() {
    let kb = bytes_to_kb(2048);
    println!("2048 bytes is {} KB", kb);

    let mb = kb_to_mb(2048.0);
    println!("2048 KB is {} MB", mb);
}

License

This project is licensed under the MIT License.

Author

Ben Santora (bensatlantik@gmail.com)

No runtime deps