notes vault library and CLI (Obsidian-compatible)
git clone https://git.lucas.co/cce-vault.git
src/lib.rs (1.9K)
1 //! The notes vault shared by cce apps.
2 //!
3 //! A vault is a folder of Markdown notes, canvases and attachments —
4 //! byte-compatible with Obsidian, which can keep working on the same files.
5 //! This crate is everything about that folder that is not UI:
6 //!
7 //! - [`parse`]: one note's properties, links, tags, headings, block ids
8 //! and tasks, with exact byte spans.
9 //! - [`index`]: every file, where each link resolves, backlinks, tags and
10 //! tasks; cached on disk by mtime and patched as files change.
11 //! - [`watch`]: a recursive, debounced watcher feeding the index.
12 //! - [`search`]: fuzzy name matching, full-text search, unlinked mentions.
13 //! - [`write`]: atomic writes, task toggling, and rename with link rewrite.
14 //! - [`canvas`]: JSON Canvas read and write, byte-exact with Obsidian.
15 //! - [`daily`]: daily notes from Obsidian's own settings and templates.
16 //! - [`markdown`]: a note as styled blocks and spans, for reading views.
17 //! - [`config`]: where the vault is (`CCE_VAULT`, or `vault { path }` in
18 //! `~/.config/cce/config.kdl`).
19 //!
20 //! It has no cce-ui dependency on purpose: the `cce-vault` CLI, tests and
21 //! any future non-GUI tool use it without a Wayland stack. There is no
22 //! daemon; each app embeds an [`Index`] and a [`VaultWatcher`].
23 //!
24 //! ```no_run
25 //! let root = cce_vault::config::vault_root(None)?;
26 //! let mut index = cce_vault::Index::open(&root, true)?;
27 //! for b in index.backlinks("Projects/cce.md") {
28 //! println!("{}:{}", b.source, b.link.line + 1);
29 //! }
30 //! index.save_cache()?;
31 //! # Ok::<(), Box<dyn std::error::Error>>(())
32 //! ```
33
34 pub mod attachments;
35 pub mod canvas;
36 pub mod config;
37 pub mod daily;
38 pub mod index;
39 pub mod markdown;
40 pub mod parse;
41 pub mod search;
42 pub mod watch;
43 pub mod write;
44
45 pub use index::{Backlink, Changes, Entry, FileKind, Index};
46 pub use parse::{Link, LinkKind, Note, Task};
47 pub use watch::VaultWatcher;
48 pub use write::{LinkEdit, RenamePlan, WriteError};