pub struct DocumentMutator<'doc> {
pub doc: &'doc mut BaseDocument,
/* private fields */
}Fields§
§doc: &'doc mut BaseDocumentDocument is public as an escape hatch, but users of this API should ideally avoid using it and prefer exposing additional functionality in DocumentMutator.
Implementations§
Source§impl DocumentMutator<'_>
impl DocumentMutator<'_>
pub fn new<'doc>(doc: &'doc mut BaseDocument) -> DocumentMutator<'doc>
pub fn node_has_parent(&self, node_id: NodeId) -> bool
pub fn previous_sibling_id(&self, node_id: NodeId) -> Option<NodeId>
pub fn next_sibling_id(&self, node_id: NodeId) -> Option<NodeId>
pub fn parent_id(&self, node_id: NodeId) -> Option<NodeId>
pub fn last_child_id(&self, node_id: NodeId) -> Option<NodeId>
pub fn child_ids(&self, node_id: NodeId) -> ThinVec<NodeId>
pub fn element_name(&self, node_id: NodeId) -> Option<&QualName>
pub fn node_at_path(&self, start_node_id: NodeId, path: &[u8]) -> NodeId
pub fn create_comment_node(&mut self, contents: &str) -> NodeId
pub fn create_text_node(&mut self, text: &str) -> NodeId
pub fn create_element( &mut self, name: QualName, attrs: Vec<Attribute>, ) -> NodeId
pub fn deep_clone_node(&mut self, node_id: NodeId) -> NodeId
pub fn set_node_text(&mut self, node_id: NodeId, value: &str)
pub fn append_text_to_node( &mut self, node_id: NodeId, text: &str, ) -> Result<(), AppendTextErr>
pub fn add_attrs_if_missing(&mut self, node_id: NodeId, attrs: Vec<Attribute>)
pub fn set_attribute(&mut self, node_id: NodeId, name: QualName, value: &str)
pub fn clear_attribute(&mut self, node_id: NodeId, name: QualName)
pub fn set_style_property(&mut self, node_id: NodeId, name: &str, value: &str)
pub fn remove_style_property(&mut self, node_id: NodeId, name: &str)
pub fn set_sub_document( &mut self, node_id: NodeId, sub_document: Box<dyn Document>, )
pub fn remove_sub_document(&mut self, node_id: NodeId)
pub fn set_custom_widget(&mut self, node_id: NodeId, widget: Box<dyn Widget>)
pub fn remove_custom_widget(&mut self, node_id: NodeId)
Sourcepub fn remove_node(&mut self, node_id: NodeId)
pub fn remove_node(&mut self, node_id: NodeId)
Remove the node from its parent but don’t drop it.
pub fn remove_and_drop_node(&mut self, node_id: NodeId) -> Option<Node>
Sourcepub fn remove_and_drop_node_with(
&mut self,
node_id: NodeId,
on_drop: &mut dyn FnMut(NodeId),
) -> Option<Node>
pub fn remove_and_drop_node_with( &mut self, node_id: NodeId, on_drop: &mut dyn FnMut(NodeId), ) -> Option<Node>
Like Self::remove_and_drop_node, but calls on_drop with the id of
every dropped node (the node itself and all of its descendants).
pub fn remove_and_drop_all_children(&mut self, node_id: NodeId)
pub fn remove_node_if_unparented(&mut self, node_id: NodeId)
Sourcepub fn remove_node_if_unparented_with(
&mut self,
node_id: NodeId,
on_drop: &mut dyn FnMut(NodeId),
)
pub fn remove_node_if_unparented_with( &mut self, node_id: NodeId, on_drop: &mut dyn FnMut(NodeId), )
Like Self::remove_node_if_unparented, but calls on_drop with the id of
every dropped node (the node itself and all of its descendants).
Sourcepub fn append_children(&mut self, parent_id: NodeId, child_ids: &[NodeId])
pub fn append_children(&mut self, parent_id: NodeId, child_ids: &[NodeId])
Remove all of the children from old_parent_id and append them to new_parent_id
pub fn insert_nodes_before( &mut self, anchor_node_id: NodeId, new_node_ids: &[NodeId], )
pub fn insert_nodes_after( &mut self, anchor_node_id: NodeId, new_node_ids: &[NodeId], )
pub fn reparent_children( &mut self, old_parent_id: NodeId, new_parent_id: NodeId, )
pub fn replace_node_with( &mut self, anchor_node_id: NodeId, new_node_ids: &[NodeId], )
Source§impl<'doc> DocumentMutator<'doc>
impl<'doc> DocumentMutator<'doc>
Trait Implementations§
Source§impl Drop for DocumentMutator<'_>
impl Drop for DocumentMutator<'_>
Auto Trait Implementations§
impl<'doc> !RefUnwindSafe for DocumentMutator<'doc>
impl<'doc> !Send for DocumentMutator<'doc>
impl<'doc> !Sync for DocumentMutator<'doc>
impl<'doc> !UnwindSafe for DocumentMutator<'doc>
impl<'doc> Freeze for DocumentMutator<'doc>
impl<'doc> Unpin for DocumentMutator<'doc>
impl<'doc> UnsafeUnpin for DocumentMutator<'doc>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert