data_storage_units 0.1.2

Unit converter for rust language
Documentation
  • Coverage
  • 83.33%
    10 out of 12 items documented5 out of 6 items with examples
  • Size
  • Source code size: 1.31 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.36 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • encoderuz/data_storage_units
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • encoderuz

Unit Converter for Rust Language

Test Current Crates.io Version

This library allows you to convert a size in bytes into kilobytes, megabytes, gigabytes, and terabytes, as well as perform conversions back to bytes.

Create a new ByteConverter instance

bytes: The number of bytes to be converted.

use data_storage_units::ByteConverter;
let converter = ByteConverter::new(1024);

Converts bytes to kilobytes (KB)

A tuple containing the value in kilobytes as f64 and the unit "KB".

let converter = ByteConverter::new(1024);
let (value, unit) = converter.to_kb();

Converts bytes to megabytes (MB)

A tuple containing the value in megabytes as f64 and the unit "MB".

let converter = ByteConverter::new(1073741824);
let (value, unit) = converter.to_mb();

Converts bytes to gigabytes (GB)

A tuple containing the value in gigabytes as f64 and the unit "GB".

let converter = ByteConverter::new(1073741824);
/let (value, unit) = converter.to_gb();

Converts bytes to terabytes (TB)

A tuple containing the value in terabytes as f64 and the unit "TB".

let converter = ByteConverter::new(1073741824);
let (value, unit) = converter.to_tb();