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: Stringdocs.format (markdown).
leading_trivia: Stringdocs.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).
impl MutDoc
The six ops as methods (two-phase borrows let a caller compute ids from the document inside the argument list).
Sourcepub fn insert(
&mut self,
to: &To,
markdown: &str,
minter: &mut dyn Minter,
) -> Result<OpResult, MutationError>
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).
Sourcepub fn update(
&mut self,
block_id: &str,
op_index: usize,
args: &UpdateArgs,
minter: &mut dyn Minter,
) -> Result<OpResult, MutationError>
pub fn update( &mut self, block_id: &str, op_index: usize, args: &UpdateArgs, minter: &mut dyn Minter, ) -> Result<OpResult, MutationError>
Sourcepub fn move_blocks(
&mut self,
block_ids: &[String],
to: &To,
op_index: usize,
) -> Result<OpResult, MutationError>
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.
Sourcepub fn remove(
&mut self,
block_ids: &[String],
op_index: usize,
expect_per: Option<&BTreeMap<String, Expect>>,
) -> Result<OpResult, MutationError>
pub fn remove( &mut self, block_ids: &[String], op_index: usize, expect_per: Option<&BTreeMap<String, Expect>>, ) -> Result<OpResult, MutationError>
Source§impl MutDoc
impl MutDoc
Sourcepub fn new(doc_id: &str, path: &str, children: Vec<MutBlock>) -> MutDoc
pub fn new(doc_id: &str, path: &str, children: Vec<MutBlock>) -> MutDoc
A document with no frontmatter and the given top-level blocks.
Sourcepub fn locate(&self, block_id: &str) -> Option<Vec<usize>>
pub fn locate(&self, block_id: &str) -> Option<Vec<usize>>
§1: find a block anywhere in the document; its path.
Sourcepub fn siblings(&self, parent: &[usize]) -> &Vec<MutBlock>
pub fn siblings(&self, parent: &[usize]) -> &Vec<MutBlock>
The sibling list a parent path names ([] → the top level).
Sourcepub fn siblings_mut(&mut self, parent: &[usize]) -> &mut Vec<MutBlock>
pub fn siblings_mut(&mut self, parent: &[usize]) -> &mut Vec<MutBlock>
Mutable MutDoc::siblings.
Sourcepub fn owner_of(&self, parent: &[usize]) -> Option<&MutBlock>
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.
Sourcepub fn mark_container_dirty(&mut self, parent: &[usize])
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.