Trait 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) -> bool
where 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) -> bool
where 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) -> bool
where 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) -> bool
where I: Iterator<Item = Cow<'static, str>>,

Set html class and return whether successful

Source

fn add_class<S>(&mut self, class: S) -> bool
where 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) -> bool
where 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) -> bool
where 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) -> bool
where 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.

Implementors§