pub struct Transform<'a> { /* private fields */ }Expand description
A mutation transaction over a Node tree: edits apply in place and are
recorded as a Change log. Create with Node::transform.
Each builder returns Result<&mut Self, ApplyError> so calls chain with ?;
an error (e.g. a path that doesn’t resolve) leaves the tree as mutated by the
changes recorded so far.
Implementations§
Source§impl<'a> Transform<'a>
impl<'a> Transform<'a>
Sourcepub fn set_attr(
&mut self,
path: Vec<usize>,
key: impl Into<String>,
value: impl Into<Value>,
) -> Result<&mut Self, ApplyError>
pub fn set_attr( &mut self, path: Vec<usize>, key: impl Into<String>, value: impl Into<Value>, ) -> Result<&mut Self, ApplyError>
Set (insert or overwrite) attribute key on the node at path.
Sourcepub fn remove_attr(
&mut self,
path: Vec<usize>,
key: impl Into<String>,
) -> Result<&mut Self, ApplyError>
pub fn remove_attr( &mut self, path: Vec<usize>, key: impl Into<String>, ) -> Result<&mut Self, ApplyError>
Remove attribute key from the node at path.
Sourcepub fn set_text(
&mut self,
path: Vec<usize>,
text: Option<String>,
) -> Result<&mut Self, ApplyError>
pub fn set_text( &mut self, path: Vec<usize>, text: Option<String>, ) -> Result<&mut Self, ApplyError>
Set the text payload of the node at path (None clears it).
Sourcepub fn set_marks(
&mut self,
path: Vec<usize>,
marks: Option<Vec<Mark>>,
) -> Result<&mut Self, ApplyError>
pub fn set_marks( &mut self, path: Vec<usize>, marks: Option<Vec<Mark>>, ) -> Result<&mut Self, ApplyError>
Replace the whole mark list of the node at path (None clears it).
Sourcepub fn set_extra(
&mut self,
path: Vec<usize>,
key: impl Into<String>,
value: impl Into<Value>,
) -> Result<&mut Self, ApplyError>
pub fn set_extra( &mut self, path: Vec<usize>, key: impl Into<String>, value: impl Into<Value>, ) -> Result<&mut Self, ApplyError>
Set (insert or overwrite) unknown top-level field key on the node at path.
Sourcepub fn remove_extra(
&mut self,
path: Vec<usize>,
key: impl Into<String>,
) -> Result<&mut Self, ApplyError>
pub fn remove_extra( &mut self, path: Vec<usize>, key: impl Into<String>, ) -> Result<&mut Self, ApplyError>
Remove unknown top-level field key from the node at path.
Sourcepub fn insert(
&mut self,
path: Vec<usize>,
index: usize,
node: Node,
) -> Result<&mut Self, ApplyError>
pub fn insert( &mut self, path: Vec<usize>, index: usize, node: Node, ) -> Result<&mut Self, ApplyError>
Insert node as a child of the node at path (the parent), at index.
Sourcepub fn remove(
&mut self,
path: Vec<usize>,
index: usize,
) -> Result<&mut Self, ApplyError>
pub fn remove( &mut self, path: Vec<usize>, index: usize, ) -> Result<&mut Self, ApplyError>
Remove the child at index of the node at path (the parent).
Sourcepub fn replace(
&mut self,
path: Vec<usize>,
node: Node,
) -> Result<&mut Self, ApplyError>
pub fn replace( &mut self, path: Vec<usize>, node: Node, ) -> Result<&mut Self, ApplyError>
Replace the node at path wholesale.
Sourcepub fn move_child(
&mut self,
path: Vec<usize>,
from: usize,
to: usize,
) -> Result<&mut Self, ApplyError>
pub fn move_child( &mut self, path: Vec<usize>, from: usize, to: usize, ) -> Result<&mut Self, ApplyError>
Relocate the child at from to to within the parent at path, without
cloning its subtree. See Change::Move.