Skip to content

sombralibre/k8s-quantity-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages