Skip to main content

NodeRef

Struct NodeRef 

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

Represents a referene to a node in the document.

Implementations§

Source§

impl NodeRef

Source

pub const fn new(cell: usize, id: usize) -> Self

Creates a new NodeRef with the given index and id.

Source§

impl NodeRef

Source

pub fn append_child(self, arena: &mut Arena, child_ref: NodeRef)

Appends a child node to this node.

§Panics

Panics if the operation fails(e.g. due to invalid NodeRef).

Source

pub fn try_append_child( self, arena: &mut Arena, child_ref: NodeRef, ) -> Result<()>

Appends a child node to this node.

Source

pub fn replace_child( self, arena: &mut Arena, target_ref: NodeRef, replacer_ref: NodeRef, )

Replace a child node with another node. Replaced child will be hard removed.

§Panics

Panics if the operation fails(e.g. due to invalid NodeRef).

Source

pub fn try_replace_child( self, arena: &mut Arena, target_ref: NodeRef, replacer_ref: NodeRef, ) -> Result<()>

Replace a child node with another node. Replaced child will be hard removed.

Source

pub fn insert_before( self, arena: &mut Arena, target_ref: NodeRef, insertee_ref: NodeRef, )

Inserts a child node before a target node.

§Panics

Panics if the operation fails(e.g. due to invalid NodeRef).

Source

pub fn try_insert_before( self, arena: &mut Arena, target_ref: NodeRef, insertee_ref: NodeRef, ) -> Result<()>

Inserts a child node before a target node.

Source

pub fn insert_after( self, arena: &mut Arena, target_ref: NodeRef, insertee_ref: NodeRef, )

Inserts a child node after a target node.

§Panics

Panics if the operation fails(e.g. due to invalid NodeRef).

Source

pub fn try_insert_after( self, arena: &mut Arena, target_ref: NodeRef, insertee_ref: NodeRef, ) -> Result<()>

Inserts a child node after a target node.

Source

pub fn remove(self, arena: &mut Arena)

Removes this node from the document. This does not remove its children. This does not remove the node from Arena.

§Panics

Panics if the operation fails(e.g. due to invalid NodeRef).

Source

pub fn try_remove(self, arena: &mut Arena) -> Result<()>

Removes this node from the document. This does not remove its children. This does not remove the node from Arena.

Source

pub fn delete(self, arena: &mut Arena)

Deletes this node from the document, including all its children. This removes the node from Arena.

§Panics

Panics if the operation fails(e.g. due to invalid NodeRef).

Source

pub fn try_delete(self, arena: &mut Arena) -> Result<()>

Removes this node from the document, including all its children. This removes the node from Arena.

Source

pub fn merge_or_append_text(self, arena: &mut Arena, index: Index)

Source

pub fn try_merge_or_append_text( self, arena: &mut Arena, index: Index, ) -> Result<()>

Source

pub fn merge_or_insert_after_text( self, arena: &mut Arena, target_ref: NodeRef, index: Index, )

Merges a given index into the text node after the target node if it can be merged, otherwise creates a new Text node and inserts it after the target node.

Panics if the operation fails(e.g. due to invalid NodeRef).

Source

pub fn try_merge_or_insert_after_text( self, arena: &mut Arena, target_ref: NodeRef, index: Index, ) -> Result<()>

Merges a given index into the text node after the target node if it can be merged, otherwise creates a new Text node and inserts it after the target node.

Source

pub fn merge_or_insert_before_text( self, arena: &mut Arena, target_ref: NodeRef, index: Index, )

Merges a given index into the text node before the target node if it can be merged, otherwise creates a new Text node and inserts it before the target node.

§Panics

Panics if the operation fails(e.g. due to invalid NodeRef).

Source

pub fn try_merge_or_insert_before_text( self, arena: &mut Arena, target_ref: NodeRef, index: Index, ) -> Result<()>

Merges a given index into the text node before the target node if it can be merged, otherwise creates a new Text node and inserts it before the target node.

Trait Implementations§

Source§

impl Clone for NodeRef

Source§

fn clone(&self) -> NodeRef

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeRef

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for NodeRef

Source§

fn default() -> NodeRef

Returns the “default value” for a type. Read more
Source§

impl Display for NodeRef

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Index<NodeRef> for Arena

Implements indexing for Arena to access nodes by NodeRef. This panics if the NodeRef is invalid.

Source§

type Output = Node

The returned type after indexing.
Source§

fn index(&self, node_ref: NodeRef) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<NodeRef> for Arena

Implements mutable indexing for Arena to access nodes by NodeRef. This panics if the NodeRef is invalid.

Source§

fn index_mut(&mut self, node_ref: NodeRef) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl PartialEq for NodeRef

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for NodeRef

Source§

impl Eq for NodeRef

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.