mdvault_core/scripting/
hooks.rs1use std::path::PathBuf;
7
8use thiserror::Error;
9
10#[derive(Debug, Clone)]
14pub struct NoteContext {
15 pub path: PathBuf,
17 pub note_type: String,
19 pub frontmatter: serde_yaml::Value,
21 pub content: String,
23}
24
25impl NoteContext {
26 pub fn new(
28 path: PathBuf,
29 note_type: String,
30 frontmatter: serde_yaml::Value,
31 content: String,
32 ) -> Self {
33 Self { path, note_type, frontmatter, content }
34 }
35}
36
37#[derive(Debug, Error)]
39pub enum HookError {
40 #[error("template not found: {0}")]
42 TemplateNotFound(String),
43
44 #[error("capture not found: {0}")]
46 CaptureNotFound(String),
47
48 #[error("macro not found: {0}")]
50 MacroNotFound(String),
51
52 #[error("hook execution failed: {0}")]
54 Execution(String),
55
56 #[error("Lua error: {0}")]
58 LuaError(String),
59
60 #[error("template render error: {0}")]
62 TemplateRender(String),
63
64 #[error("capture execution error: {0}")]
66 CaptureExecution(String),
67
68 #[error("macro execution error: {0}")]
70 MacroExecution(String),
71
72 #[error("IO error: {0}")]
74 Io(#[from] std::io::Error),
75}