From 17875ae65fcf5c9aae43804bf1baf099f367725e Mon Sep 17 00:00:00 2001 From: axtloss Date: Thu, 25 Jan 2024 12:58:17 +0100 Subject: progress --- src/core/storage.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/core/storage.rs (limited to 'src/core/storage.rs') 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 +} + +#[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 { + let db = Structsy::open(path)?; + db.define::()? +} + + +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 -- cgit v1.2.3