Skip to main content

WriteEngine

Struct WriteEngine 

Source
pub struct WriteEngine { /* private fields */ }

Implementations§

Source§

impl WriteEngine

Source

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

Source

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.

Source

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

Source

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.

Source

pub fn with_default_journal(settings: Settings) -> Result<Self, AgdError>

Source§

impl WriteEngine

Source

pub fn review(&self, journal_id: &str) -> Result<(), AgdError>

Source

pub fn journal(&self) -> Result<Vec<JournalRecord>, AgdError>

Source

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.

Source

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

Source

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

Source

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.

Trait Implementations§

Source§

impl Debug for WriteEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more