Trait SelectorSubject
pub trait SelectorSubject: Sized {
// Required methods
fn local_name(&self) -> &str;
fn attribute(&self, name: &str) -> Option<&str>;
fn parent(&self) -> Option<Self>;
fn nth_child_index(&self) -> usize;
fn nth_of_type_index(&self) -> usize;
// Provided methods
fn has_id(&self, id: &str) -> bool { ... }
fn has_class(&self, class: &str) -> bool { ... }
}html and http only.Expand description
A read-only view of an element, providing exactly what the selector
matcher needs. Implement it for your own tree to match selectors
against it, or use the in-memory Dom.
Self is expected to be a cheap handle (e.g. an index into an arena),
since parent returns it by value.
Attribute and tag names are matched ASCII case-insensitively (per HTML),
while class names, ids and attribute values are case-sensitive by
default. The name passed to attribute
is already ASCII-lowercased.
Required Methods§
fn local_name(&self) -> &str
fn local_name(&self) -> &str
The element’s tag name (any ASCII case).
fn attribute(&self, name: &str) -> Option<&str>
fn attribute(&self, name: &str) -> Option<&str>
The value of the attribute with the given (ASCII-lowercased) name.
fn nth_child_index(&self) -> usize
fn nth_child_index(&self) -> usize
The element’s 1-based position among all element siblings
(for :nth-child). A root element returns 1.
fn nth_of_type_index(&self) -> usize
fn nth_of_type_index(&self) -> usize
The element’s 1-based position among element siblings of the same
type (for :nth-of-type). A root element returns 1.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".