Struct scraper::element_ref::ElementRef
source · [−]pub struct ElementRef<'a> { /* private fields */ }
Expand description
Wrapper around a reference to an element node.
This wrapper implements the Element
trait from the selectors
crate, which allows it to be
matched against CSS selectors.
Implementations
sourceimpl<'a> ElementRef<'a>
impl<'a> ElementRef<'a>
sourcepub fn wrap(node: NodeRef<'a, Node>) -> Option<Self>
pub fn wrap(node: NodeRef<'a, Node>) -> Option<Self>
Wraps a NodeRef
only if it references a Node::Element
.
sourcepub fn select<'b>(&self, selector: &'b Selector) -> Select<'a, 'b>ⓘNotable traits for Select<'a, 'b>impl<'a, 'b> Iterator for Select<'a, 'b> type Item = ElementRef<'a>;
pub fn select<'b>(&self, selector: &'b Selector) -> Select<'a, 'b>ⓘNotable traits for Select<'a, 'b>impl<'a, 'b> Iterator for Select<'a, 'b> type Item = ElementRef<'a>;
Returns an iterator over descendent elements matching a selector.
sourcepub fn inner_html(&self) -> String
pub fn inner_html(&self) -> String
Returns the inner HTML of this element.
Methods from Deref<Target = NodeRef<'a, Node>>
sourcepub fn prev_sibling(&self) -> Option<NodeRef<'a, T>>
pub fn prev_sibling(&self) -> Option<NodeRef<'a, T>>
Returns the previous sibling of this node.
sourcepub fn next_sibling(&self) -> Option<NodeRef<'a, T>>
pub fn next_sibling(&self) -> Option<NodeRef<'a, T>>
Returns the next sibling of this node.
sourcepub fn first_child(&self) -> Option<NodeRef<'a, T>>
pub fn first_child(&self) -> Option<NodeRef<'a, T>>
Returns the first child of this node.
sourcepub fn last_child(&self) -> Option<NodeRef<'a, T>>
pub fn last_child(&self) -> Option<NodeRef<'a, T>>
Returns the last child of this node.
sourcepub fn has_siblings(&self) -> bool
pub fn has_siblings(&self) -> bool
Returns true if this node has siblings.
sourcepub fn has_children(&self) -> bool
pub fn has_children(&self) -> bool
Returns true if this node has children.
sourcepub fn prev_siblings(&self) -> PrevSiblings<'a, T>
pub fn prev_siblings(&self) -> PrevSiblings<'a, T>
Returns an iterator over previous siblings.
sourcepub fn next_siblings(&self) -> NextSiblings<'a, T>
pub fn next_siblings(&self) -> NextSiblings<'a, T>
Returns an iterator over next siblings.
sourcepub fn first_children(&self) -> FirstChildren<'a, T>
pub fn first_children(&self) -> FirstChildren<'a, T>
Returns an iterator over first children.
sourcepub fn last_children(&self) -> LastChildren<'a, T>
pub fn last_children(&self) -> LastChildren<'a, T>
Returns an iterator over last children.
sourcepub fn traverse(&self) -> Traverse<'a, T>
pub fn traverse(&self) -> Traverse<'a, T>
Returns an iterator which traverses the subtree starting at this node.
sourcepub fn descendants(&self) -> Descendants<'a, T>
pub fn descendants(&self) -> Descendants<'a, T>
Returns an iterator over this node and its descendants.
Trait Implementations
sourceimpl<'a> Clone for ElementRef<'a>
impl<'a> Clone for ElementRef<'a>
sourcefn clone(&self) -> ElementRef<'a>
fn clone(&self) -> ElementRef<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'a> Debug for ElementRef<'a>
impl<'a> Debug for ElementRef<'a>
sourceimpl<'a> Deref for ElementRef<'a>
impl<'a> Deref for ElementRef<'a>
sourceimpl<'a> Element for ElementRef<'a>
impl<'a> Element for ElementRef<'a>
Note: will never match against non-tree-structure pseudo-classes.
type Impl = Simple
sourcefn opaque(&self) -> OpaqueElement
fn opaque(&self) -> OpaqueElement
Converts self into an opaque representation.
fn parent_element(&self) -> Option<Self>
sourcefn parent_node_is_shadow_root(&self) -> bool
fn parent_node_is_shadow_root(&self) -> bool
Whether the parent node of this element is a shadow root.
sourcefn containing_shadow_host(&self) -> Option<Self>
fn containing_shadow_host(&self) -> Option<Self>
The host of the containing shadow root, if any.
sourcefn is_pseudo_element(&self) -> bool
fn is_pseudo_element(&self) -> bool
Whether we’re matching on a pseudo-element.
fn is_part(&self, _name: &LocalName) -> bool
sourcefn is_same_type(&self, other: &Self) -> bool
fn is_same_type(&self, other: &Self) -> bool
Whether this element and the other
element have the same local name and namespace.
sourcefn exported_part(&self, _: &LocalName) -> Option<LocalName>
fn exported_part(&self, _: &LocalName) -> Option<LocalName>
Returns the mapping from the exportparts
attribute in the regular
direction, that is, inner-tree -> outer-tree. Read more
sourcefn imported_part(&self, _: &LocalName) -> Option<LocalName>
fn imported_part(&self, _: &LocalName) -> Option<LocalName>
Returns the mapping from the exportparts
attribute in the reverse
direction, that is, in an outer-tree -> inner-tree direction. Read more
sourcefn prev_sibling_element(&self) -> Option<Self>
fn prev_sibling_element(&self) -> Option<Self>
Skips non-element nodes
sourcefn next_sibling_element(&self) -> Option<Self>
fn next_sibling_element(&self) -> Option<Self>
Skips non-element nodes
fn is_html_element_in_html_document(&self) -> bool
fn has_local_name(&self, name: &LocalName) -> bool
sourcefn has_namespace(&self, namespace: &Namespace) -> bool
fn has_namespace(&self, namespace: &Namespace) -> bool
Empty string for no namespace
fn attr_matches(
&self,
ns: &NamespaceConstraint<&Namespace>,
local_name: &LocalName,
operation: &AttrSelectorOperation<&String>
) -> bool
fn match_non_ts_pseudo_class<F>(
&self,
_pc: &NonTSPseudoClass,
_context: &mut MatchingContext<'_, Self::Impl>,
_flags_setter: &mut F
) -> bool
fn match_pseudo_element(
&self,
_pe: &PseudoElement,
_context: &mut MatchingContext<'_, Self::Impl>
) -> bool
sourcefn is_html_slot_element(&self) -> bool
fn is_html_slot_element(&self) -> bool
Returns whether the element is an HTML
fn has_id(&self, id: &LocalName, case_sensitivity: CaseSensitivity) -> bool
fn has_class(&self, name: &LocalName, case_sensitivity: CaseSensitivity) -> bool
sourcefn is_root(&self) -> bool
fn is_root(&self) -> bool
Returns whether this element matches :root
,
i.e. whether it is the root element of a document. Read more
sourcefn pseudo_element_originating_element(&self) -> Option<Self>
fn pseudo_element_originating_element(&self) -> Option<Self>
The parent of a given pseudo-element, after matching a pseudo-element selector. Read more
sourcefn assigned_slot(&self) -> Option<Self>
fn assigned_slot(&self) -> Option<Self>
Returns the assigned
sourcefn ignores_nth_child_selectors(&self) -> bool
fn ignores_nth_child_selectors(&self) -> bool
Returns whether this element should ignore matching nth child selector. Read more
sourceimpl<'a> PartialEq<ElementRef<'a>> for ElementRef<'a>
impl<'a> PartialEq<ElementRef<'a>> for ElementRef<'a>
sourcefn eq(&self, other: &ElementRef<'a>) -> bool
fn eq(&self, other: &ElementRef<'a>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ElementRef<'a>) -> bool
fn ne(&self, other: &ElementRef<'a>) -> bool
This method tests for !=
.
sourceimpl<'a> Serialize for ElementRef<'a>
impl<'a> Serialize for ElementRef<'a>
impl<'a> Copy for ElementRef<'a>
impl<'a> Eq for ElementRef<'a>
impl<'a> StructuralEq for ElementRef<'a>
impl<'a> StructuralPartialEq for ElementRef<'a>
Auto Trait Implementations
impl<'a> !RefUnwindSafe for ElementRef<'a>
impl<'a> !Send for ElementRef<'a>
impl<'a> !Sync for ElementRef<'a>
impl<'a> Unpin for ElementRef<'a>
impl<'a> !UnwindSafe for ElementRef<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more