aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 0022703..5eb8b5b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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),
}