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§
sourcefn build(self) -> HtmlElement
fn build(self) -> HtmlElement
Construct html elements
Provided Methods§
sourcefn set_tag<S>(&mut self, tag: S) -> boolwhere
S: Into<Cow<'static, str>>,
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
sourcefn get_attribute(&self, name: &str) -> Option<&AttributeValue>
fn get_attribute(&self, name: &str) -> Option<&AttributeValue>
Get the html attribute based on the given name
sourcefn mut_attribute(&mut self, name: &str) -> Option<&mut AttributeValue>
fn mut_attribute(&mut self, name: &str) -> Option<&mut AttributeValue>
Get the mutable html attribute based on the given name
sourcefn set_attribute<S>(&mut self, name: S, value: AttributeValue) -> boolwhere
S: Into<Cow<'static, str>>,
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.
sourcefn get_id(&self) -> Option<&str>
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.
sourcefn set_id<S>(&mut self, id: S) -> boolwhere
S: Into<Cow<'static, str>>,
fn set_id<S>(&mut self, id: S) -> boolwhere S: Into<Cow<'static, str>>,
Set html id and return whether successful
sourcefn get_classes(&self) -> impl Iterator<Item = &str>
fn get_classes(&self) -> impl Iterator<Item = &str>
Get the legal html class.
sourcefn set_classes<I>(&mut self, classes: I) -> boolwhere
I: Iterator<Item = Cow<'static, str>>,
fn set_classes<I>(&mut self, classes: I) -> boolwhere I: Iterator<Item = Cow<'static, str>>,
Set html class and return whether successful
sourcefn add_class<S>(&mut self, class: S) -> boolwhere
S: Into<Cow<'static, str>>,
fn add_class<S>(&mut self, class: S) -> boolwhere S: Into<Cow<'static, str>>,
Add html class and return whether successful
sourcefn remove_class<S>(&mut self, class: &str) -> bool
fn remove_class<S>(&mut self, class: &str) -> bool
Remove html class and return whether successful
sourcefn get_child(&self, index: usize) -> Option<&HtmlNode>
fn get_child(&self, index: usize) -> Option<&HtmlNode>
Get the child element based on the given index
sourcefn mut_child(&mut self, index: usize) -> Option<&mut HtmlNode>
fn mut_child(&mut self, index: usize) -> Option<&mut HtmlNode>
Get the mutable child element based on the given index
sourcefn set_child<T>(&mut self, index: usize, child: T) -> boolwhere
T: Into<HtmlNode>,
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
sourcefn add_child<T>(&mut self, child: T) -> boolwhere
T: Into<HtmlNode>,
fn add_child<T>(&mut self, child: T) -> boolwhere T: Into<HtmlNode>,
Add a child element and return whether successful
sourcefn get_children(&self) -> impl Iterator<Item = &HtmlNode>
fn get_children(&self) -> impl Iterator<Item = &HtmlNode>
Remove the child element based on the given index and return whether successful
sourcefn mut_children(&mut self) -> impl Iterator<Item = &mut HtmlNode>
fn mut_children(&mut self) -> impl Iterator<Item = &mut HtmlNode>
Get the mutable child element based on the given index
sourcefn set_children<I>(&mut self, children: I) -> boolwhere
I: Iterator<Item = HtmlNode>,
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