Skip to main content

MutDoc

Struct MutDoc 

Source
pub struct MutDoc {
    pub doc_id: String,
    pub path: String,
    pub format: String,
    pub leading_trivia: String,
    pub frontmatter_raw: Option<String>,
    pub children: Vec<MutBlock>,
}
Expand description

A document in the working tree (§1 MutDoc).

Fields§

§doc_id: String§path: String§format: String

docs.format (markdown).

§leading_trivia: String

docs.leading_trivia.

§frontmatter_raw: Option<String>

The current revision’s frontmatter blob + docs.frontmatter_trivia, or None when the document has no frontmatter.

§children: Vec<MutBlock>

The top-level blocks.

Implementations§

Source§

impl MutDoc

The six ops as methods (two-phase borrows let a caller compute ids from the document inside the argument list).

Source

pub fn insert( &mut self, to: &To, markdown: &str, minter: &mut dyn Minter, ) -> Result<OpResult, MutationError>

op_insert without the §1.2 order CAS (op_index 0).

Source

pub fn update( &mut self, block_id: &str, op_index: usize, args: &UpdateArgs, minter: &mut dyn Minter, ) -> Result<OpResult, MutationError>

Source

pub fn move_blocks( &mut self, block_ids: &[String], to: &To, op_index: usize, ) -> Result<OpResult, MutationError>

op_move without the §1.2 order CAS.

Source

pub fn remove( &mut self, block_ids: &[String], op_index: usize, expect_per: Option<&BTreeMap<String, Expect>>, ) -> Result<OpResult, MutationError>

Source

pub fn split( &mut self, block_id: &str, at: &[usize], op_index: usize, expect: Option<&Expect>, minter: &mut dyn Minter, ) -> Result<OpResult, MutationError>

Source

pub fn merge( &mut self, block_ids: &[String], op_index: usize, separator: Option<&str>, expect_per: Option<&BTreeMap<String, Expect>>, ) -> Result<OpResult, MutationError>

Source§

impl MutDoc

Source

pub fn new(doc_id: &str, path: &str, children: Vec<MutBlock>) -> MutDoc

A document with no frontmatter and the given top-level blocks.

Source

pub fn iter(&self) -> impl Iterator<Item = &MutBlock>

Every block at every depth, pre-order.

Source

pub fn locate(&self, block_id: &str) -> Option<Vec<usize>>

§1: find a block anywhere in the document; its path.

Source

pub fn contains(&self, block_id: &str) -> bool

Whether block_id is anywhere in the document.

Source

pub fn siblings(&self, parent: &[usize]) -> &Vec<MutBlock>

The sibling list a parent path names ([] → the top level).

Source

pub fn siblings_mut(&mut self, parent: &[usize]) -> &mut Vec<MutBlock>

Source

pub fn block(&self, path: &[usize]) -> &MutBlock

The block at path.

§Panics

If path is empty or does not name a block.

Source

pub fn block_mut(&mut self, path: &[usize]) -> &mut MutBlock

Mutable MutDoc::block.

§Panics

If path is empty or does not name a block.

Source

pub fn owner_of(&self, parent: &[usize]) -> Option<&MutBlock>

§1 owner_of: the block owning the sibling list at parent, or None at the top level.

Source

pub fn mark_container_dirty(&mut self, parent: &[usize])

§1 mark_container_dirty: a structural change to a sibling list invalidates its owner’s raw; the top level needs no marking.

Source

pub fn all_ids(&self) -> Vec<String>

The ids of every block, pre-order.

Trait Implementations§

Source§

impl Clone for MutDoc

Source§

fn clone(&self) -> MutDoc

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MutDoc

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for MutDoc

Source§

fn eq(&self, other: &MutDoc) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MutDoc

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.