Skip to main content

Transaction

Struct Transaction 

Source
pub struct Transaction { /* private fields */ }
Expand description

In-memory plan bound to one notebook. Drop discards; no begin/rollback.

Implementations§

Source§

impl Transaction

Source

pub async fn commit(self) -> Result<CommitOutcome, NbError>

Validate-all, apply-all, at most one Git checkpoint.

Source§

impl Transaction

Source

pub fn add_note( &mut self, path: &str, title: Option<&str>, content: &str, tags: &[String], ) -> Result<(), NbError>

Source

pub fn add_todo( &mut self, path: &str, title: &str, description: Option<&str>, tasks: &[String], tags: &[String], ) -> Result<(), NbError>

Source

pub fn add_bookmark( &mut self, path: &str, url: &str, title: Option<&str>, tags: &[String], comment: Option<&str>, ) -> Result<(), NbError>

Source

pub fn add_folder(&mut self, path: &str) -> Result<(), NbError>

Source

pub fn delete_note(&mut self, target: NoteTarget) -> Result<(), NbError>

Source

pub fn delete_folder( &mut self, target: NoteTarget, recursive: bool, ) -> Result<(), NbError>

Delete a folder. recursive = false refuses non-empty folders, listing their contents; recursive = true removes the whole subtree. Marker files (.gitkeep) and .index files alone do not count as contents.

Source

pub fn move_note( &mut self, target: NoteTarget, destination: &str, ) -> Result<(), NbError>

Source

pub fn mark_task_done( &mut self, target: NoteTarget, task_number: Option<u32>, ) -> Result<(), NbError>

Source

pub fn unmark_task_done( &mut self, target: NoteTarget, task_number: Option<u32>, ) -> Result<(), NbError>

Source

pub fn replace_note_body( &mut self, target: NoteTarget, new_body: &str, fingerprint: Fingerprint, ) -> Result<(), NbError>

Source

pub fn edit_note_substring( &mut self, target: NoteTarget, pattern: &str, replacement: &str, occurrence: Occurrence, expected_count: u32, fingerprint: Option<Fingerprint>, ) -> Result<(), NbError>

Source

pub fn edit_note_lines( &mut self, target: NoteTarget, edits: Vec<LineEdit>, ) -> Result<(), NbError>

Source

pub fn retitle_note( &mut self, target: NoteTarget, title: &str, ) -> Result<(), NbError>

Source

pub fn edit_note_tags( &mut self, target: NoteTarget, add: &[String], remove: &[String], ) -> Result<(), NbError>

Source

pub fn assert_revision(&mut self, expected: &str) -> Result<(), NbError>

Assert the notebook revision is unchanged since capture.

Composable optimistic-concurrency precondition: evaluated at commit time, before any materialization, so a mismatch refuses cleanly with nothing applied. Capture the expected revision with [crate::git::git_rev_parse_in] (&["HEAD"]) at the moment the plan’s assumptions are taken, and push this op into the same Transaction.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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