Trait serde_html::Element

source ·
pub trait Element {
Show 19 methods // Required methods fn build(self) -> HtmlElement; fn get_tag(&self) -> &str; // Provided methods fn set_tag<S>(&mut self, tag: S) -> bool where S: Into<Cow<'static, str>> { ... } fn get_attribute(&self, name: &str) -> Option<&AttributeValue> { ... } fn mut_attribute(&mut self, name: &str) -> Option<&mut AttributeValue> { ... } fn set_attribute<S>(&mut self, name: S, value: AttributeValue) -> bool where S: Into<Cow<'static, str>> { ... } fn get_id(&self) -> Option<&str> { ... } fn set_id<S>(&mut self, id: S) -> bool where S: Into<Cow<'static, str>> { ... } fn get_classes(&self) -> impl Iterator<Item = &str> { ... } fn set_classes<I>(&mut self, classes: I) -> bool where I: Iterator<Item = Cow<'static, str>> { ... } fn add_class<S>(&mut self, class: S) -> bool where S: Into<Cow<'static, str>> { ... } fn remove_class<S>(&mut self, class: &str) -> bool { ... } fn get_child(&self, index: usize) -> Option<&HtmlNode> { ... } fn mut_child(&mut self, index: usize) -> Option<&mut HtmlNode> { ... } fn set_child<T>(&mut self, index: usize, child: T) -> bool where T: Into<HtmlNode> { ... } fn add_child<T>(&mut self, child: T) -> bool where T: Into<HtmlNode> { ... } fn get_children(&self) -> impl Iterator<Item = &HtmlNode> { ... } fn mut_children(&mut self) -> impl Iterator<Item = &mut HtmlNode> { ... } fn set_children<I>(&mut self, children: I) -> bool where I: Iterator<Item = HtmlNode> { ... }
}
Expand description

The trait of all html elements

Required Methods§

source

fn build(self) -> HtmlElement

Construct html elements

source

fn get_tag(&self) -> &str

Get the tag of the element, all html elements must have tag

Provided Methods§

source

fn set_tag<S>(&mut self, tag: S) -> boolwhere S: Into<Cow<'static, str>>,

Change the tag of the element and return whether the change is successful

source

fn get_attribute(&self, name: &str) -> Option<&AttributeValue>

Get the html attribute based on the given name

source

fn mut_attribute(&mut self, name: &str) -> Option<&mut AttributeValue>

Get the mutable html attribute based on the given name

source

fn set_attribute<S>(&mut self, name: S, value: AttributeValue) -> boolwhere S: Into<Cow<'static, str>>,

According to the given name, set the html attribute and return whether it is successful.

source

fn get_id(&self) -> Option<&str>

Get the legal html id.

Note that Some will be returned only when the id exists and the value is a string.

source

fn set_id<S>(&mut self, id: S) -> boolwhere S: Into<Cow<'static, str>>,

Set html id and return whether successful

source

fn get_classes(&self) -> impl Iterator<Item = &str>

Get the legal html class.

source

fn set_classes<I>(&mut self, classes: I) -> boolwhere I: Iterator<Item = Cow<'static, str>>,

Set html class and return whether successful

source

fn add_class<S>(&mut self, class: S) -> boolwhere S: Into<Cow<'static, str>>,

Add html class and return whether successful

source

fn remove_class<S>(&mut self, class: &str) -> bool

Remove html class and return whether successful

source

fn get_child(&self, index: usize) -> Option<&HtmlNode>

Get the child element based on the given index

source

fn mut_child(&mut self, index: usize) -> Option<&mut HtmlNode>

Get the mutable child element based on the given index

source

fn set_child<T>(&mut self, index: usize, child: T) -> boolwhere T: Into<HtmlNode>,

Set the child element based on the given index and return whether successful

source

fn add_child<T>(&mut self, child: T) -> boolwhere T: Into<HtmlNode>,

Add a child element and return whether successful

source

fn get_children(&self) -> impl Iterator<Item = &HtmlNode>

Remove the child element based on the given index and return whether successful

source

fn mut_children(&mut self) -> impl Iterator<Item = &mut HtmlNode>

Get the mutable child element based on the given index

source

fn set_children<I>(&mut self, children: I) -> boolwhere I: Iterator<Item = HtmlNode>,

Set the child element based on the given index and return whether successful

Object Safety§

This trait is not object safe.

Implementors§