pub struct WriteEngine { /* private fields */ }Implementations§
Source§impl WriteEngine
impl WriteEngine
Sourcepub fn capture(
&self,
template_key: &str,
draft: &CaptureDraft,
body: &str,
prompts: &BTreeMap<String, String>,
dry_run: bool,
context: &WriteContext,
) -> Result<Mutation, AgdError>
pub fn capture( &self, template_key: &str, draft: &CaptureDraft, body: &str, prompts: &BTreeMap<String, String>, dry_run: bool, context: &WriteContext, ) -> Result<Mutation, AgdError>
Captures through a template. A dry run renders the same diff and touches nothing: no directory, lock, journal entry or file. A real capture is computed once before any directory is created, so a refused capture leaves nothing behind either.
Source§impl WriteEngine
impl WriteEngine
Sourcepub fn edit(
&self,
item_ref: &str,
intent: &EditIntent,
dry_run: bool,
context: &WriteContext,
) -> Result<Mutation, AgdError>
pub fn edit( &self, item_ref: &str, intent: &EditIntent, dry_run: bool, context: &WriteContext, ) -> Result<Mutation, AgdError>
Applies one edit. A dry run computes the same diff from the current bytes and touches nothing: no lock, journal entry or file.
Sourcepub fn edit_batch(
&self,
edits: &[ItemEdit],
dry_run: bool,
context: &WriteContext,
) -> Result<BatchMutation, AgdError>
pub fn edit_batch( &self, edits: &[ItemEdit], dry_run: bool, context: &WriteContext, ) -> Result<BatchMutation, AgdError>
Applies several edits as one transaction: every target is resolved and its edit computed first, and if any is refused nothing is written and the error names that target. Otherwise each file is written once and journaled under one transaction, so one undo reverts them all. A dry run touches nothing.
Source§impl WriteEngine
impl WriteEngine
Sourcepub fn new(settings: Settings, journal_path: PathBuf) -> Result<Self, AgdError>
pub fn new(settings: Settings, journal_path: PathBuf) -> Result<Self, AgdError>
An engine writing under the configured roots and journaling to
journal_path. Opening it only reads; interrupted writes are settled
by the next write to their file, or by resolve_conflicts.
pub fn with_default_journal(settings: Settings) -> Result<Self, AgdError>
Source§impl WriteEngine
impl WriteEngine
pub fn review(&self, journal_id: &str) -> Result<(), AgdError>
pub fn journal(&self) -> Result<Vec<JournalRecord>, AgdError>
Sourcepub fn journal_conflicts(&self) -> Result<Vec<JournalRecord>, AgdError>
pub fn journal_conflicts(&self) -> Result<Vec<JournalRecord>, AgdError>
Interrupted writes whose file now holds neither their pre- nor their post-image. Reads the journal and the files only.
Sourcepub fn resolve_conflicts(
&self,
context: &WriteContext,
) -> Result<Vec<JournalRecord>, AgdError>
pub fn resolve_conflicts( &self, context: &WriteContext, ) -> Result<Vec<JournalRecord>, AgdError>
Settles every interrupted write: recoverable ones as committed or unapplied, and conflicts as resolved, keeping each file exactly as it is on disk. Returns the entries marked resolved.
Source§impl WriteEngine
impl WriteEngine
Sourcepub fn refile(
&self,
item_ref: &str,
target_ref: &str,
dry_run: bool,
context: &WriteContext,
) -> Result<RefileResult, AgdError>
pub fn refile( &self, item_ref: &str, target_ref: &str, dry_run: bool, context: &WriteContext, ) -> Result<RefileResult, AgdError>
Moves an item’s subtree under another heading, in one file or across two as one journal transaction (the target written first, so an interruption never loses the item). A dry run touches nothing.
Source§impl WriteEngine
impl WriteEngine
Sourcepub fn undo(
&self,
journal_id: &str,
context: &WriteContext,
) -> Result<UndoResult, AgdError>
pub fn undo( &self, journal_id: &str, context: &WriteContext, ) -> Result<UndoResult, AgdError>
Reverts one journal entry, or every file of its transaction, given the entry’s id or the transaction id. A change is reverted only where the file still holds what it wrote; otherwise nothing is written and the error says what changed and what to do.