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) -> bool
fn set_tag<S>(&mut self, tag: S) -> bool
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) -> bool
fn set_attribute<S>(&mut self, name: S, value: AttributeValue) -> bool
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 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) -> bool
fn set_classes<I>(&mut self, classes: I) -> bool
Set 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
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.