pub struct Pattern { /* private fields */ }Expand description
A compiled libxml2-flavour pattern. Match nodes via
Self::matches.
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn compile(src: &str) -> Result<Self, String>
pub fn compile(src: &str) -> Result<Self, String>
Compile a pattern source string into a matcher.
Returns Err on syntax errors or grammar features outside the
libxml2 pattern subset.
Sourcepub fn matches(&self, node: &Node<'_>) -> bool
pub fn matches(&self, node: &Node<'_>) -> bool
Does node match this pattern? Walks upward via parent
pointers, so the node must be attached to a tree.
Sourcepub fn matches_attribute(
&self,
attr_name: &str,
parent: Option<&Node<'_>>,
) -> bool
pub fn matches_attribute( &self, attr_name: &str, parent: Option<&Node<'_>>, ) -> bool
Like matches, but for an attribute candidate.
Attributes are a distinct node type in this tree, so they cannot be
reinterpreted as an &Node to feed matches — the
two have different layouts. The caller supplies the attribute’s
name and owner element; the leftmost (@name / @*) step is
matched against the name and the rest of the pattern against the
owner-element ancestor chain.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnsafeUnpin for Pattern
impl UnwindSafe for Pattern
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more