NodeInner

Struct NodeInner 

Source
pub struct NodeInner { /* private fields */ }
Expand description

The inner data of a node in the parse tree.

Each node has:

  • 0 or more children
  • XML content (element or text)
  • A parent (except for root)
  • A position among siblings
  • An optional match area tag
  • Kind-specific data (Base or Branch)

Implementations§

Source§

impl NodeInner

Source

pub fn first_partner(&self, type_flags: MatchType) -> Option<NodeRef>

Returns the first partner that matches the given type.

Source

pub fn is_match(&self, type_flags: MatchType) -> bool

Returns true if the match type includes the given flags.

Source§

impl NodeInner

Source

pub fn new_base(content: Option<XmlContent>) -> Self

Creates a new base node with the given content.

Source

pub fn new_branch(content: Option<XmlContent>) -> Self

Creates a new branch node with the given content.

Source

pub fn id(&self) -> u64

Returns the unique ID of this node.

Source

pub fn is_base(&self) -> bool

Returns true if this is a base node.

Source

pub fn is_branch(&self) -> bool

Returns true if this is a branch node.

Source

pub fn content(&self) -> Option<&XmlContent>

Returns the content of this node.

Source

pub fn content_mut(&mut self) -> Option<&mut XmlContent>

Returns a mutable reference to the content.

Source

pub fn set_content(&mut self, content: Option<XmlContent>)

Sets the content of this node.

Source

pub fn child_count(&self) -> usize

Returns the number of children.

Source

pub fn child(&self, index: usize) -> Option<&NodeRef>

Returns a reference to the child at the given index.

Source

pub fn children(&self) -> &[NodeRef]

Returns the children as a slice.

Source

pub fn parent(&self) -> &Weak<RefCell<NodeInner>>

Returns a weak reference to the parent.

Source

pub fn child_pos(&self) -> i32

Returns the child position (0-based index among siblings, -1 for root).

Source

pub fn match_area(&self) -> Option<&Rc<MatchArea>>

Returns the match area, if set.

Source

pub fn set_match_area(&mut self, area: Option<Rc<MatchArea>>)

Sets the match area.

Source

pub fn kind(&self) -> &NodeKind

Returns the node kind.

Source

pub fn kind_mut(&mut self) -> &mut NodeKind

Returns a mutable reference to the node kind.

Source

pub fn has_left_sibling(&self) -> bool

Returns true if this node has a left sibling.

Source

pub fn has_right_sibling(&self) -> bool

Returns true if this node has a right sibling.

Source

pub fn match_type(&self) -> Option<MatchType>

Returns the match type for branch nodes, None for base nodes.

Source

pub fn get_base_match(&self) -> Option<&Weak<RefCell<NodeInner>>>

Returns the base match for branch nodes (a weak reference to the matched base node). Returns None for base nodes or if no match has been set.

Source

pub fn set_base_match(&mut self, base: &NodeRef)

Sets the base match for a branch node. Does nothing for base nodes.

Source

pub fn set_match_type(&mut self, mt: MatchType)

Sets the match type for a branch node. Does nothing for base nodes.

Source

pub fn del_base_match(&mut self)

Clears the base match for a branch node.

Source§

impl NodeInner

Helper functions that work with NodeRef.

Source

pub fn add_child_to_ref(parent_ref: &NodeRef, child_ref: NodeRef)

Adds a child node. Must be called on the NodeRef wrapper.

Source

pub fn add_child_at_to_ref( parent_ref: &NodeRef, index: usize, child_ref: NodeRef, )

Inserts a child at the given index.

Source

pub fn replace_child_to_ref( parent_ref: &NodeRef, index: usize, child_ref: NodeRef, )

Replaces a child at the given index.

Source

pub fn remove_child_to_ref(parent_ref: &NodeRef, index: usize)

Removes the child at the given index.

Source

pub fn remove_children_to_ref(parent_ref: &NodeRef)

Removes all children.

Source

pub fn left_sibling_of_ref(node_ref: &NodeRef) -> Option<NodeRef>

Gets the left sibling of a node.

Source

pub fn right_sibling_of_ref(node_ref: &NodeRef) -> Option<NodeRef>

Gets the right sibling of a node.

Source

pub fn init_base_node_owner(node_ref: &NodeRef)

Initializes the owner weak refs for a base node’s MatchedNodes. Must be called after the node is wrapped in Rc.

Trait Implementations§

Source§

impl Debug for NodeInner

Source§

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

Formats the value using the given formatter. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.