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 it’s 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], )
Sourcepub fn prepend_nodes(&mut self, parent_id: NodeId, node_ids: &[NodeId])
pub fn prepend_nodes(&mut self, parent_id: NodeId, node_ids: &[NodeId])
ParentNode’s prepend(): insert the nodes at the start of parent_id’s
children (ParentNode’s append() is append_children)
Sourcepub fn replace_children(&mut self, parent_id: NodeId, node_ids: &[NodeId])
pub fn replace_children(&mut self, parent_id: NodeId, node_ids: &[NodeId])
ParentNode’s replaceChildren(): replace all of parent_id’s children
with the given nodes. The existing children are detached rather than
dropped, so that references to them remain valid.
Sourcepub fn before_node(&mut self, anchor_id: NodeId, node_ids: &[NodeId])
pub fn before_node(&mut self, anchor_id: NodeId, node_ids: &[NodeId])
ChildNode’s before(): insert the nodes before anchor_id. The
insertion point is after the nearest preceding sibling which isn’t
itself being inserted (or at the start of the parent if there is none).
Does nothing if the anchor has no parent.
Sourcepub fn after_node(&mut self, anchor_id: NodeId, node_ids: &[NodeId])
pub fn after_node(&mut self, anchor_id: NodeId, node_ids: &[NodeId])
ChildNode’s after(): insert the nodes after anchor_id. The insertion
point is before the nearest following sibling which isn’t itself being
inserted (or at the end of the parent if there is none). Does nothing if
the anchor has no parent.
Sourcepub fn replace_with_nodes(&mut self, anchor_id: NodeId, node_ids: &[NodeId])
pub fn replace_with_nodes(&mut self, anchor_id: NodeId, node_ids: &[NodeId])
ChildNode’s replaceWith(): replace anchor_id with the nodes in its
parent’s child list. If the anchor is itself one of the inserted nodes,
they are inserted at its old position (the spec’s “viable next sibling”
handling). The anchor is detached rather than dropped, so references to
it remain valid. Does nothing if the anchor has no parent.
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
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> ⓘ
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> ⓘ
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 more