summaryrefslogtreecommitdiffstats
path: root/cli/src/main.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-07-29 00:29:40 +0200
committerGustav Sörnäs <gustav@sornas.net>2021-07-29 00:29:40 +0200
commit157790ff3452be04b6a14c1bec7aab821a4a8725 (patch)
tree7222496a802c16106b1a1c7b9d177a630da2dcb2 /cli/src/main.rs
parent1bb5514fa9885a4a186659c4084aa7da091b9b1a (diff)
downloadmoney-157790ff3452be04b6a14c1bec7aab821a4a8725.tar.gz
hash posts
Diffstat (limited to 'cli/src/main.rs')
-rw-r--r--cli/src/main.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs
index 9ab5a55..656107d 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -2,12 +2,15 @@ use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};
use std::convert::{AsRef, TryFrom};
use std::fs;
+use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf};
+use twox_hash::XxHash64;
type Account = String;
type Category = String;
#[derive(Debug)]
+#[derive(Hash)]
#[derive(Deserialize, Serialize)]
enum TransactionKind {
Expense,
@@ -16,6 +19,7 @@ enum TransactionKind {
}
#[derive(Debug)]
+#[derive(Hash)]
#[derive(Deserialize, Serialize)]
struct Transaction {
description: String,
@@ -27,6 +31,7 @@ struct Transaction {
}
#[derive(Debug)]
+#[derive(Hash)]
#[derive(Deserialize, Serialize)]
struct Post {
transaction: Transaction,
@@ -63,6 +68,15 @@ impl Store {
}
Some(res)
}
+
+ fn write(&self) {
+ for post in &self.posts {
+ let mut h = XxHash64::default();
+ post.hash(&mut h);
+ let file = h.finish();
+ println!("{}: {:?}", file, post);
+ }
+ }
}
impl Post {
@@ -94,5 +108,6 @@ fn main() {
// });
// post.write(&"test").unwrap();
let store = Store::open(PathBuf::from("store")).unwrap();
- println!("{:#?}", store);
+ // println!("{:#?}", store);
+ store.write();
}