pub trait Element: Clone + Debug {
Show 13 methods
// Required methods
fn opaque(&self) -> OpaqueElement;
fn parent(&self) -> Option<Self>;
fn prev_sibling(&self) -> Option<Self>;
fn next_sibling(&self) -> Option<Self>;
fn first_child(&self) -> Option<Self>;
fn local_name(&self) -> &str;
// Provided methods
fn id(&self) -> Option<&str> { ... }
fn classes(&self) -> impl Iterator<Item = &str> { ... }
fn attribute(&self, name: &str) -> Option<&str> { ... }
fn state(&self) -> ElementState { ... }
fn has_custom_state(&self, name: &str) -> bool { ... }
fn is_empty(&self) -> bool { ... }
fn is_root(&self) -> bool { ... }
}Expand description
A handle to a node in the toolkit’s widget tree.
Implement this for a cheap handle type, such as &Node or an arena index
paired with a reference to the arena, and the styler can match selectors
against your tree. Everything except identity, tree navigation and the
element name has a default that reports nothing.
Tree-structural pseudo-classes (:first-child, :nth-of-type(), :empty
and friends) are answered from the navigation methods. The interactive
ones come from state, and :state(name) from
has_custom_state.
Required Methods§
Sourcefn opaque(&self) -> OpaqueElement
fn opaque(&self) -> OpaqueElement
A value that identifies this element and no other for as long as the tree is alive.
For a handle that is a reference, OpaqueElement::new(node) is the
natural choice. For an arena index, use
opaque_element_from_index.
fn parent(&self) -> Option<Self>
fn prev_sibling(&self) -> Option<Self>
fn next_sibling(&self) -> Option<Self>
fn first_child(&self) -> Option<Self>
Sourcefn local_name(&self) -> &str
fn local_name(&self) -> &str
The name matched by a type selector, such as button.
Provided Methods§
Sourcefn classes(&self) -> impl Iterator<Item = &str>
fn classes(&self) -> impl Iterator<Item = &str>
The names matched by class selectors, such as .primary.
Sourcefn attribute(&self, name: &str) -> Option<&str>
fn attribute(&self, name: &str) -> Option<&str>
The value of an attribute, for [name] and [name="value"] selectors.
fn state(&self) -> ElementState
Sourcefn has_custom_state(&self, name: &str) -> bool
fn has_custom_state(&self, name: &str) -> bool
Whether the element is in the custom state name, for :state(name).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".