Struct tl::NodeHandle
source · pub struct NodeHandle(/* private fields */);
Expand description
A detached, external handle to a HTML node, originally obtained from a Parser
It contains an identifier that uniquely identifies an HTML node.
In particular, it is an index into the global HTML tag table managed by the Parser
.
To get a Node
out of a NodeHandle
, call NodeHandle::get()
A common way to model self referential/recursive graphs is to have one “global” vector
of nodes, and store indices into the vector instead of references.
In the case of tl, the “global” HTML tag vector is stored in the Parser
and NodeHandle
represents the index.
Because NodeHandle
is only an index and completely detached from anything, you need to pass a parser to NodeHandle::get()
Implementations§
source§impl NodeHandle
impl NodeHandle
sourcepub fn new(node: InnerNodeHandle) -> Self
pub fn new(node: InnerNodeHandle) -> Self
Creates a new handle to the given node
sourcepub fn get<'p, 'buf>(&self, parser: &'p Parser<'buf>) -> Option<&'p Node<'buf>>
pub fn get<'p, 'buf>(&self, parser: &'p Parser<'buf>) -> Option<&'p Node<'buf>>
Returns a reference to the node that is associated to this specific handle
It is an error to pass in the wrong parser.
It will either return None
if this index points outside of the nodes table,
or it will return the one it points to.
sourcepub fn get_mut<'p, 'buf>(
&self,
parser: &'p mut Parser<'buf>
) -> Option<&'p mut Node<'buf>>
pub fn get_mut<'p, 'buf>( &self, parser: &'p mut Parser<'buf> ) -> Option<&'p mut Node<'buf>>
Returns a mutable reference to the node that is associated to this specific handle
It is an error to pass in the wrong parser.
It will either return None
if this index points outside of the nodes table,
or it will return the one it points to.
sourcepub fn get_inner(&self) -> InnerNodeHandle
pub fn get_inner(&self) -> InnerNodeHandle
Returns the internal unique Node ID that maps to a specific node in the node table
Trait Implementations§
source§impl Clone for NodeHandle
impl Clone for NodeHandle
source§fn clone(&self) -> NodeHandle
fn clone(&self) -> NodeHandle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for NodeHandle
impl Debug for NodeHandle
source§impl Hash for NodeHandle
impl Hash for NodeHandle
source§impl Ord for NodeHandle
impl Ord for NodeHandle
source§fn cmp(&self, other: &NodeHandle) -> Ordering
fn cmp(&self, other: &NodeHandle) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for NodeHandle
impl PartialEq for NodeHandle
source§fn eq(&self, other: &NodeHandle) -> bool
fn eq(&self, other: &NodeHandle) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for NodeHandle
impl PartialOrd for NodeHandle
source§fn partial_cmp(&self, other: &NodeHandle) -> Option<Ordering>
fn partial_cmp(&self, other: &NodeHandle) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more