pub trait NodeExt {
// Required methods
fn is_element<S: AsRef<str> + ?Sized>(&self, name: &S) -> bool;
fn is_processing_instruction<S: AsRef<str> + ?Sized>(
&self,
name: &S,
) -> bool;
fn element_attr_keys<'a>(
&'a self,
) -> Result<Box<dyn Iterator<Item = String> + 'a>>;
fn get_attr_value<S: AsRef<str> + ?Sized>(
&self,
name: &S,
) -> Result<Option<String>>;
fn set_attr_value<S: AsRef<str> + ?Sized, V: AsRef<str> + ?Sized>(
&self,
name: &S,
value: &V,
) -> Result<()>;
}
markup5ever_rcdom
only.Expand description
Extensions for Node
Required Methods§
Sourcefn is_element<S: AsRef<str> + ?Sized>(&self, name: &S) -> bool
fn is_element<S: AsRef<str> + ?Sized>(&self, name: &S) -> bool
Checks if the node is an element with the given name.
This function ignore namespaces.
Sourcefn is_processing_instruction<S: AsRef<str> + ?Sized>(&self, name: &S) -> bool
fn is_processing_instruction<S: AsRef<str> + ?Sized>(&self, name: &S) -> bool
Checks if the node is a processing instruction with the given name.
Sourcefn element_attr_keys<'a>(
&'a self,
) -> Result<Box<dyn Iterator<Item = String> + 'a>>
fn element_attr_keys<'a>( &'a self, ) -> Result<Box<dyn Iterator<Item = String> + 'a>>
Returns an iterator over the attribute keys of the element node.
This function returns an empty iterator if the node is not an element. Only the local names of the attributes are returned, ignoring namespaces.
Sourcefn get_attr_value<S: AsRef<str> + ?Sized>(
&self,
name: &S,
) -> Result<Option<String>>
fn get_attr_value<S: AsRef<str> + ?Sized>( &self, name: &S, ) -> Result<Option<String>>
Gets the value of the attribute with the given name.
This function returns Ok(None)
if the node is not an element or if the attribute does not exist.
This function ignores namespaces and only checks the local name of the attribute.
Sourcefn set_attr_value<S: AsRef<str> + ?Sized, V: AsRef<str> + ?Sized>(
&self,
name: &S,
value: &V,
) -> Result<()>
fn set_attr_value<S: AsRef<str> + ?Sized, V: AsRef<str> + ?Sized>( &self, name: &S, value: &V, ) -> Result<()>
Sets the value of the attribute with the given name.
This function creates the attribute if it does not exist.
This function ignores namespaces and only checks the local name of the attribute.
Returns Ok(())
if the node is not an element.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.