[][src]Struct syntax_tree::Node

pub struct Node<T> { /* fields omitted */ }

Methods

impl<T> Node<T> where
    T: Eq + Hash
[src]

pub fn new_leaf(text: String) -> Node<T>[src]

Create new leaf node.

pub fn new() -> Node<T>[src]

Create new node.

pub fn new_root(string: &str) -> Node<T>[src]

Create new root node.

pub fn id(&self) -> &String[src]

Get the ID of the node.

pub fn is_leaf(&self) -> bool[src]

Check whether this node is a

pub fn add_child(&mut self, child: Node<T>)[src]

Add a child to this node.

pub fn text(&self) -> String[src]

Get text the node (or children) is/are holding.

pub fn length(&self) -> usize[src]

Length of the underlying text.

pub fn infos(&self) -> Iter<Rc<T>>[src]

Get iterator over all infos this node has.

pub fn add_info(&mut self, info: Rc<T>)[src]

Add info to the node.

pub fn clear_infos(&mut self)[src]

Clear all infos from this node without recursion in children.

pub fn remove_info(
    &mut self,
    start_idx: usize,
    end_idx: usize,
    info: Rc<T>,
    recurse: bool
) -> Option<Vec<Node<T>>>
[src]

Remove info from the node. Specify recurse whether the info should be removed from children as well. Since a node can end up useless without info, it might have to be replaced by its children which are then returned by this method.

pub fn has_info(&self, info: &T) -> bool[src]

Check if the node has the passed info.

pub fn set(
    &mut self,
    start_idx: usize,
    end_idx: usize,
    info: Rc<T>
) -> Option<Vec<Node<T>>>
[src]

Set syntax/format info for the passed range. The range is the passed start index (inclusive) to the passed end index (exclusive). Returns a list of nodes to replace the current one in case that is needed (optional).

pub fn unset(&mut self, start_idx: usize, end_idx: usize, info: Rc<T>)[src]

Unset the passed syntax/format info for the passed range. The range is the passed start index (inclusive) to the passed end index (exclusive).

pub fn insert(&mut self, idx: usize, ch: char)[src]

Insert a char in the underlying text.

pub fn insert_str(&mut self, idx: usize, string: &str)[src]

Insert a string in the underlying text.

pub fn push(&mut self, ch: char)[src]

Push a char to the underlying text.

pub fn push_str(&mut self, string: &str)[src]

Push a string to the underlying text.

pub fn child_count(&self) -> usize[src]

Get the count of children under this node.

pub fn remove(&mut self, idx: usize, count: usize) -> (bool, bool)[src]

Remove a count of characters from the underlying text starting at idx. Removing a character might lead to having an empty leaf left. Method will return boolean tuple with two elements (bool, bool). The first boolean will determine whether the node is unnecessary now, the second boolean determined whether parent may need to regroup its children.

pub fn children(&self) -> &[Node<T>][src]

Get a slice of all children under this node.

pub fn give_listener(&mut self, l: &Option<Rc<Listener<T>>>)[src]

Give node change listener.

pub fn take_listener(&mut self) -> Option<Rc<Listener<T>>>[src]

Take the change listener from this node (if any).

pub fn pre_order_iter(&self) -> PreOrder<T>[src]

Get a depth first pre order iterator.

pub fn leaf_iter(&self) -> impl Iterator<Item = Item<T>>[src]

Get a leaf iterator.

Trait Implementations

impl<T> Debug for Node<T> where
    T: Ord + Hash + Debug
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Node<T>

impl<T> !Send for Node<T>

impl<T> !Sync for Node<T>

impl<T> Unpin for Node<T>

impl<T> !UnwindSafe for Node<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,