diff options
author | axtloss <axtlos@disroot.org> | 2024-01-25 12:58:17 +0100 |
---|---|---|
committer | axtloss <axtlos@disroot.org> | 2024-01-25 12:58:17 +0100 |
commit | 17875ae65fcf5c9aae43804bf1baf099f367725e (patch) | |
tree | a21f89b4fa5b7944e24e96c398f95f29a648f75d /src | |
parent | 085c6c2a32be55c03a0bd1d54122c25579d9a1e8 (diff) | |
download | fsverify-17875ae65fcf5c9aae43804bf1baf099f367725e.tar.gz fsverify-17875ae65fcf5c9aae43804bf1baf099f367725e.tar.bz2 |
progress
Diffstat (limited to 'src')
-rw-r--r-- | src/core/mod.rs | 1 | ||||
-rw-r--r-- | src/core/storage.rs | 36 | ||||
-rw-r--r-- | src/main.rs | 6 |
3 files changed, 41 insertions, 2 deletions
diff --git a/src/core/mod.rs b/src/core/mod.rs new file mode 100644 index 0000000..e626ba5 --- /dev/null +++ b/src/core/mod.rs @@ -0,0 +1 @@ +pub mod storage;
\ No newline at end of file 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 diff --git a/src/main.rs b/src/main.rs index e7a11a9..bcab8e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +mod core; + fn main() { - println!("Hello, world!"); -} + +}
\ No newline at end of file |