obsidian_parser/lib.rs
1//! `obsidian-parser` - Blazingly fast Rust library for parsing and analyzing [Obsidian](https://obsidian.md) vaults
2//!
3//! Provides idiomatic APIs for:
4//! - Parsing individual Obsidian notes with frontmatter properties
5//! - Analyzing entire vaults as knowledge graphs
6//! - Extracting semantic relationships between notes
7//!
8//! ## Key Features
9//! * ⚡ **High Performance**: Parses 1000+ notes in under 3ms
10//! * 🧠 **Knowledge Graphs**: Built-in integration with [`petgraph`](https://docs.rs/petgraph/latest/petgraph) for advanced analysis
11//! * 🧩 **Flexible API**: Supports both in-memory and on-disk note representations
12//! * 🔍 **Frontmatter Parsing**: Extract YAML properties with [`serde`](https://docs.rs/serde/latest/serde) compatibility
13//! * 🌐 **Link Analysis**: Identify connections between notes
14//!
15//! ## Usage
16//! Add to `Cargo.toml`:
17//! ```toml
18//! [dependencies]
19//! obsidian-parser = { version = "0.4", features = ["petgraph", "rayon"] }
20//! ```
21//!
22//! ## Examples
23//!
24//! ### Basic Parsing
25//! ```no_run
26//! use obsidian_parser::prelude::*;
27//! use serde::Deserialize;
28//!
29//! // Parse single file with `HashMap`
30//! let note_hashmap = ObFileInMemory::from_file_default("note.md").unwrap();
31//!
32//! println!("Content: {}", note_hashmap.content().unwrap());
33//! println!("Properties: {:#?}", note_hashmap.properties().unwrap().unwrap());
34//!
35//! // Parse single file with custom struct
36//! #[derive(Clone, Deserialize)]
37//! struct NoteProperties {
38//! created: String,
39//! tags: Vec<String>,
40//! priority: u8,
41//! }
42//!
43//! let note_with_serde: ObFileInMemory<NoteProperties> = ObFileInMemory::from_file("note.md").unwrap();
44//! ```
45//!
46//! ### Vault Analysis
47//! ```no_run
48//! use obsidian_parser::prelude::*;
49//!
50//! // Load entire vault
51//! let vault = Vault::open_default("/path/to/vault").unwrap();
52//!
53//! // Check for duplicate note names
54//! if !vault.check_unique_note_name() {
55//! eprintln!("Duplicate note names detected!");
56//! }
57//!
58//! // Access parsed files
59//! for file in vault.files {
60//! println!("Note: {:?}", file.path());
61//! }
62//! ```
63//!
64//! ### Graph Analysis (requires [`petgraph`](https://docs.rs/petgraph/latest/petgraph) feature)
65//! ```no_run
66//! #[cfg(feature = "petgraph")]
67//! {
68//! use obsidian_parser::prelude::*;
69//! use petgraph::dot::{Dot, Config};
70//!
71//! let vault = Vault::open_default("/path/to/vault").unwrap();
72//! let graph = vault.get_digraph();
73//!
74//! // Export to Graphviz format
75//! println!("{:?}", Dot::with_config(&graph, &[Config::EdgeNoLabel]));
76//!
77//! // Find most connected note
78//! let most_connected = graph.node_indices()
79//! .max_by_key(|n| graph.edges(*n).count())
80//! .unwrap();
81//! println!("Knowledge hub: {}", graph[most_connected]);
82//! }
83//! ```
84//!
85//! ## Performance
86//! Optimized for large vaults:
87//! - 🚀 1000 files parsed in 2.6 ms (avg)
88//! - 💾 Peak memory: 900KB per 1000 notes
89//!
90//! Parallel processing via Rayon (enable `rayon` feature)
91
92#![warn(missing_docs)]
93#![warn(clippy::pedantic)]
94#![warn(clippy::cargo)]
95#![warn(clippy::nursery)]
96#![warn(clippy::perf)]
97#![warn(clippy::unwrap_used)]
98#![warn(clippy::panic)]
99#![warn(clippy::needless_pass_by_value)]
100#![warn(clippy::unreadable_literal)]
101#![warn(clippy::missing_const_for_fn)]
102#![warn(clippy::as_conversions)]
103#![cfg_attr(docsrs, feature(doc_cfg))]
104
105pub mod error;
106pub mod obfile;
107pub mod prelude;
108pub mod vault;
109
110#[cfg(test)]
111pub(crate) mod test_utils;