data_storage_units

Crates.iodata_storage_units
lib.rsdata_storage_units
version0.1.2
sourcesrc
created_at2024-08-23 10:08:53.442262
updated_at2024-08-23 10:42:29.652253
descriptionUnit converter for rust language
homepagehttps://github.com/encoderuz/unit_converter
repositoryhttps://github.com/encoderuz/unit_converter
max_upload_size
id1349001
size1,317,842
Abduqodir (encoderuz)

documentation

https://docs.rs/data_storage_units

README

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();
Commit count: 0

cargo fmt