Skip to main content

Node

Struct Node 

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

A single HTML node.

Implementations§

Source§

impl Node

Source

pub fn kind(&self) -> Kind

Get the kind of the node.

Source

pub fn parent(&self) -> Option<Node>

Get the node’s parent node, returning None if there isn’t one.

Source

pub fn child_nodes(&self) -> Vec<Node>

Get the node’s child nodes.

Source

pub fn siblings(&self) -> Vec<Node>

Get the sibling nodes of the node.

Source

pub fn next(&self) -> Option<Node>

Get the next sibling of the node, returning None if there isn’t one.

Source

pub fn prev(&self) -> Option<Node>

Get the previous sibling of the node, returning None if there isn’t one.

Source

pub fn outer_html(&self) -> Option<String>

Get the node’s outer HTML.

Source

pub fn has_attr<T: AsRef<str>>(&self, attr_name: T) -> bool

Test if this node has an attribute. Case insensitive.

Source

pub fn set_attr<K: AsRef<str>, V: AsRef<str>>( &mut self, key: K, value: V, ) -> Result<(), HtmlError>

Set an attribute value on this node.

If this node already has an attribute with the key, its value is updated; otherwise, a new attribute is added.

Source

pub fn remove_attr<T: AsRef<str>>(&mut self, attr: T) -> Result<(), HtmlError>

Remove an attribute from this node.

Source

pub fn text(&self) -> Option<String>

Get the text of this node, if it is a text node.

Source

pub fn data(&self) -> Option<String>

Get the data of this node, if it is a data node or comment.

Trait Implementations§

Source§

impl Display for Node

Source§

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

Returns the outer HTML of the node.

Source§

impl Drop for Node

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<Element> for Node

Source§

fn from(value: Element) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<Node> for Document

Source§

type Error = HtmlError

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

fn try_from(value: Node) -> Result<Self, HtmlError>

Performs the conversion.
Source§

impl TryFrom<Node> for Element

Source§

type Error = HtmlError

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

fn try_from(value: Node) -> Result<Self, HtmlError>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

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> 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.