Expand description
§BytePrefix
A library to format bytes as specified by The NIST Reference on Constants, Units, and Uncertainty referenced at Prefixes for Binary Multiples
§Adding the crate to your crate
$ cargo add byte_prefix
§Usage
// Import the crate
use byte_prefix::calc_bytes;
// The bytes to convert
let size = 1024usize as f32;
// Call `calc_bytes()` function passing the `size` as arguments
let formatted_file_size = calc_bytes(size);
§LICENSE
This crate is licensed under Apache-2.0 or MIT and all contributions will bear the same licenses.
§Code of Conduct
All contributions and discussions must adhere to the Rust Code Of Conduct
Enums§
- Byte
Format - An enum representing the supported formats
Constants§
- EiB
- Size of a
EiB
which is1024 * 1024 * 1024 * 1024 * 1024 * 1024
- GiB
- Size of a
GiB
which is1024 * 1024 * 1024
- KiB
- Size of a
KiB
which is1024
- MiB
- Size of a
MiB
which is1024 * 1024
- PiB
- Size of a
PiB
which is1024 * 1024 * 1024 * 1024 * 1024
- TiB
- Size of a
TiB
which is1024 * 1024 * 1024 * 1024
Functions§
- calc_
bytes - Call
calc_bytes
and pass in the size of the bytes as af32
in order to format the size of a file into bytes