aboutsummaryrefslogtreecommitdiff
path: root/src/core/storage.rs
diff options
context:
space:
mode:
authoraxtloss <axtlos@disroot.org>2024-01-25 12:58:17 +0100
committeraxtloss <axtlos@disroot.org>2024-01-25 12:58:17 +0100
commit17875ae65fcf5c9aae43804bf1baf099f367725e (patch)
treea21f89b4fa5b7944e24e96c398f95f29a648f75d /src/core/storage.rs
parent085c6c2a32be55c03a0bd1d54122c25579d9a1e8 (diff)
downloadfsverify-17875ae65fcf5c9aae43804bf1baf099f367725e.tar.gz
fsverify-17875ae65fcf5c9aae43804bf1baf099f367725e.tar.bz2
progress
Diffstat (limited to 'src/core/storage.rs')
-rw-r--r--src/core/storage.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/core/storage.rs b/src/core/storage.rs
new file mode 100644
index 0000000..a4bb1bb
--- /dev/null
+++ b/src/core/storage.rs
@@ -0,0 +1,36 @@
+
+use structsy::{Structsy, StructsyError, StructsyTx};
+use structsy_derive::{Persistent, queries};
+
+#[derive(Persistent)]
+struct DirectoryNode {
+ dirname: string,
+ path: string,
+ files: Vec<FileNode>
+}
+
+#[derive(PersistentEmbedded)]
+struct FileNode {
+ filename: string,
+ path: string,
+ hash: string,
+ combined_hash: string,
+}
+#[queries(MyData)]
+trait FileNode {
+ fn search(self, name:&str) -> Self;
+}
+
+pub fn open_db(path: string) -> Result<Structsy, StructsyError> {
+ let db = Structsy::open(path)?;
+ db.define::<DirectoryNode>()?
+}
+
+
+pub fn add(dir: DirectoryNode) -> Result<(), StructsyError> {
+ let db = open_db("my_db.db")?;
+ let mut tx = db.begin()?;
+ tx.insert(&dir)?;
+ tx.commit()?;
+ Ok(())
+} \ No newline at end of file