diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -2,7 +2,9 @@ use std::collections::HashMap; use std::fmt; use std::ops::AddAssign; -#[derive(Clone, Copy)] +use serde::Serialize; + +#[derive(Clone, Copy, Serialize)] pub struct Capital { principal: f64, interest: f64, @@ -22,6 +24,7 @@ impl AddAssign for Capital { } } +#[derive(Serialize)] pub struct Simulation<'a> { st: SimState, updates: SimUpdates<'a>, @@ -140,7 +143,7 @@ impl<'a> Simulation<'a> { } } -#[derive(Clone)] +#[derive(Clone, Serialize)] struct SimState { period: u32, principal: f64, @@ -179,7 +182,7 @@ impl SimState { } } -#[derive(Clone)] +#[derive(Clone, Serialize)] pub struct Quota { period: u32, payed: Capital, @@ -206,7 +209,7 @@ impl fmt::Display for Quota { } } -#[derive(Debug, Default)] +#[derive(Debug, Default, Serialize)] pub struct SimUpdates<'a> { periodically: Vec<(u32, Vec<&'a SimUpdate>)>, by_month: HashMap<u32, Vec<&'a SimUpdate>>, @@ -247,7 +250,7 @@ impl<'a> SimUpdates<'a> { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize)] pub enum SimUpdate { Amortize(f64), } |