rialo_s_native_token/
lib.rs1#![allow(clippy::arithmetic_side_effects)]
4
5pub const KELVINS_PER_RLO: u64 = 1_000_000_000;
7
8pub fn kelvins_to_rlo(kelvins: u64) -> f64 {
10 kelvins as f64 / KELVINS_PER_RLO as f64
11}
12
13pub fn rlo_to_kelvins(rlo: f64) -> u64 {
15 (rlo * KELVINS_PER_RLO as f64) as u64
16}
17
18use std::fmt::{Debug, Display, Formatter, Result};
19pub struct Rlo(pub u64);
20
21impl Rlo {
22 fn write_in_rlo(&self, f: &mut Formatter<'_>) -> Result {
23 write!(
24 f,
25 "◎{}.{:09}",
26 self.0 / KELVINS_PER_RLO,
27 self.0 % KELVINS_PER_RLO
28 )
29 }
30}
31
32impl Display for Rlo {
33 fn fmt(&self, f: &mut Formatter<'_>) -> Result {
34 self.write_in_rlo(f)
35 }
36}
37
38impl Debug for Rlo {
39 fn fmt(&self, f: &mut Formatter<'_>) -> Result {
40 self.write_in_rlo(f)
41 }
42}