brk_core/structs/
dollars.rs1use derive_deref::Deref;
2use serde::Serialize;
3use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
4
5use super::Cents;
6
7#[derive(
8 Debug, Default, Clone, Copy, Deref, FromBytes, Immutable, IntoBytes, KnownLayout, Serialize,
9)]
10pub struct Dollars(f64);
11
12impl From<f64> for Dollars {
13 fn from(value: f64) -> Self {
14 Self(value)
15 }
16}
17
18impl From<Cents> for Dollars {
19 fn from(value: Cents) -> Self {
20 Self(f64::from(value) / 100.0)
21 }
22}
23
24impl From<Dollars> for f64 {
25 fn from(value: Dollars) -> Self {
26 value.0
27 }
28}