#quantity #parser #resources #k8s-openapi

k8s_quantity_parser

A simple parser for rust k8s_openapi resource Quantity

3 unstable releases

0.1.0 Apr 29, 2022
0.0.2 Apr 29, 2022
0.0.1 Apr 29, 2022

#9 in #quantity

Download history 14/week @ 2024-02-22 8/week @ 2024-02-29 34/week @ 2024-03-28 19/week @ 2024-04-04

53 downloads per month

MIT license

11KB
197 lines

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)

Dependencies

~41MB
~654K SLoC