k8s_quantity_parser

Crates.iok8s_quantity_parser
lib.rsk8s_quantity_parser
version0.1.0
sourcesrc
created_at2022-04-29 17:37:05.835812
updated_at2022-04-29 23:17:07.703963
descriptionA simple parser for rust k8s_openapi resource Quantity.
homepagehttps://github.com/sombralibre/k8s-quantity-parser
repositoryhttps://github.com/sombralibre/k8s-quantity-parser
max_upload_size
id577451
size12,402
Alejandro Llanes (sombralibre)

documentation

https://docs.rs/k8s_quantity_parser/0.1.0

README

k8s-quantity-parser

A simple parser for rust k8s_openapi::apimachinery::pkg::api::resource::Quantity

Install

[dependencies]
k8s_quantity_parser = "0.0.1"

Usage

use k8s_openapi::apimachinery::pkg::api::resource::Quantity;
use k8s_quantity_parser::QuantityParser;

// Parse memory values to bytes
let mib = Quantity("1Mi".into());
let ret: i64 = 1048576;
assert_eq!(mib.to_bytes().ok().flatten().unwrap(), ret);

// Parse cpu values to milli units of CPU.
let cpu = Quantity("4".into());
let ret: i64 = 4000;
assert_eq!(cpu.to_milli_cpus().ok().flatten().unwrap(), ret)

Commit count: 9

cargo fmt