pub struct MilliCpus(/* private fields */);Expand description
A CPU limit in thousandths of a CPU.
In JSON it is a decimal number of CPUs with at most three decimal places
(1.5 is 1500 millicpus); nothing after parsing uses floating point. The
expected cpu.max is <millicpus × 100> 100000 and Docker’s NanoCpus
is millicpus × 10⁶.
§Examples
use stratum_node_core::MilliCpus;
let cpus: MilliCpus = serde_json::from_str("1.5")?;
assert_eq!(cpus.get(), 1500);
assert_eq!(cpus.cpu_max(), "150000 100000");
assert_eq!(cpus.nano_cpus(), 1_500_000_000);
assert_eq!(serde_json::to_string(&cpus)?, "1.5");
assert!(serde_json::from_str::<MilliCpus>("0.0005").is_err());
assert!(serde_json::from_str::<MilliCpus>("-1").is_err());Implementations§
Trait Implementations§
impl Copy for MilliCpus
Source§impl<'de> Deserialize<'de> for MilliCpus
impl<'de> Deserialize<'de> for MilliCpus
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for MilliCpus
Source§impl Ord for MilliCpus
impl Ord for MilliCpus
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for MilliCpus
impl PartialOrd for MilliCpus
impl StructuralPartialEq for MilliCpus
Auto Trait Implementations§
impl Forget for MilliCpus
impl Freeze for MilliCpus
impl Move for MilliCpus
impl RefUnwindSafe for MilliCpus
impl Send for MilliCpus
impl Sync for MilliCpus
impl Unpin for MilliCpus
impl UnsafeUnpin for MilliCpus
impl UnwindSafe for MilliCpus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more