My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: init kasten

+47 -1
+43
src/types/kasten.rs
··· 1 + use std::path::PathBuf; 2 + 3 + use color_eyre::eyre::Result; 4 + 5 + use crate::types::Workspace; 6 + 7 + /// The `Kasten` that stores the `Link`s between `Zettel`s 8 + #[derive(Debug, Clone)] 9 + pub struct Kasten { 10 + /// Private field so it can only be instantiated from a `Path` 11 + _private: (), 12 + // / Connection to the sqlite database inside the `Workspace` 13 + pub ws: Workspace, 14 + } 15 + 16 + impl Kasten { 17 + /// Given a path, try to construct a `Kasten`. 18 + pub async fn index(root: impl Into<PathBuf>) -> Result<Self> { 19 + let ws = Workspace::instansiate(root).await?; 20 + 21 + Ok(Self { _private: (), ws }) 22 + } 23 + } 24 + 25 + #[cfg(test)] 26 + mod tests { 27 + use std::{ 28 + fs::{File, create_dir_all}, 29 + path::PathBuf, 30 + }; 31 + 32 + use crate::types::Kasten; 33 + 34 + #[tokio::test] 35 + async fn test_instantiation() { 36 + let path = PathBuf::from("/tmp/filaments/.filaments/filaments.db"); 37 + create_dir_all(path.parent().unwrap()).unwrap(); 38 + let _ = File::create(&path).unwrap(); 39 + let _k = Kasten::index(dbg!(&path.parent().unwrap().parent().unwrap())) 40 + .await 41 + .unwrap(); 42 + } 43 + }
+3
src/types/mod.rs
··· 20 20 mod workspace; 21 21 pub use workspace::Workspace; 22 22 23 + mod kasten; 24 + pub use kasten::Kasten; 25 + 23 26 mod frontmatter; 24 27 pub use frontmatter::FrontMatter;
+1 -1
src/types/workspace.rs
··· 85 85 let path = PathBuf::from("/tmp/filaments/.filaments/filaments.db"); 86 86 create_dir_all(path.parent().unwrap()).unwrap(); 87 87 let _ = File::create(&path).unwrap(); 88 - let _ws = Workspace::instansiate(dbg!(&path.parent().unwrap().parent().unwrap())) 88 + let _k = Workspace::instansiate(dbg!(&path.parent().unwrap().parent().unwrap())) 89 89 .await 90 90 .unwrap(); 91 91 }