Crates.io | memory-size-type |
lib.rs | memory-size-type |
version | 0.5.0 |
source | src |
created_at | 2021-10-04 09:42:42.138767 |
updated_at | 2022-01-02 15:16:15.426266 |
description | A data type for dealing with memory sizes |
homepage | |
repository | https://github.com/flying7eleven/memory-size-type |
max_upload_size | |
id | 460042 |
size | 22,483 |
This crate provides the MemorySize
data type as a size unit. This might help errors during conversion between different
units as well as comfort for printing the managed size as a human-readable value.
To use this library, you just have to add the following lines into your projects Cargo.toml
:
[dependencies.memory-size-type]
version = "0.5.0"
default-features = false
features = ["std"]
The crate is seperated into several features to reduce its size (even with this small crate). You can use the following features to enable the stuff you really need in your project:
Feature | Description |
---|---|
std | Include features like implementations for std::fmt::Debug and std::fmt::Display |
deprecated | Include the deprecated features like the MemorySize type. |
There are different use-cases for this library. The following examples represent just some possible usages.
use memory_size_type::Byte;
let size_info_byte = Byte::from(1024);
use memory_size_type::Byte;
let some_bytes = Byte::from(1024);
let some_more_bytes = Byte::from(1024);
assert_eq!(some_bytes + some_more_bytes, 2048);