NodeDataRef

Struct NodeDataRef 

Source
pub struct NodeDataRef<T> { /* private fields */ }
Expand description

Holds a strong reference to a node, but dereferences to some component inside of it.

Implementations§

Source§

impl<T> NodeDataRef<T>

Core methods for NodeDataRef.

Provides construction and access methods for typed references to node data.

Source

pub fn new<F>(rc: NodeRef, f: F) -> NodeDataRef<T>
where F: FnOnce(&Node) -> &T,

Create a NodeDataRef for a component in a given node.

Source

pub fn new_opt<F>(rc: NodeRef, f: F) -> Option<NodeDataRef<T>>
where F: FnOnce(&Node) -> Option<&T>,

Create a NodeDataRef for and a component that may or may not be in a given node.

Source

pub fn as_node(&self) -> &NodeRef

Access the corresponding node.

Source§

impl NodeDataRef<ElementData>

Element-specific methods for NodeDataRef.

Provides convenience methods for working with element nodes.

Source

pub fn text_contents(&self) -> String

Return the concatenation of all text nodes in this subtree.

Source

pub fn local_name(&self) -> &LocalName

Returns the local name of the element without any namespace prefix.

§Examples
use brik::parse_html;
use brik::traits::*;

let doc = parse_html().one("<div>Hello</div>");
let div = doc.select_first("div").unwrap();
assert_eq!(div.local_name().as_ref(), "div");

Trait Implementations§

Source§

impl<T> Clone for NodeDataRef<T>

Implements Clone for NodeDataRef.

Clones the NodeDataRef by cloning the underlying NodeRef and copying the type information. Avoids requiring T: Clone.

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for NodeDataRef<T>

Available on non-crate feature safe only.

Implements Debug for NodeDataRef (unsafe mode).

Formats the referenced data for debugging using the data’s Debug impl.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Deref for NodeDataRef<T>

Available on non-crate feature safe only.

Implements Deref for NodeDataRef (unsafe mode).

Allows transparent access to the underlying node data using unsafe pointer dereferencing for performance.

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl Element for NodeDataRef<ElementData>

Implements selectors::Element for NodeDataRef.

Provides the selectors crate interface for CSS selector matching on Brik’s ElementData nodes. This implementation enables full CSS selector support including element relationships, attributes, pseudo-classes, and namespace matching.

Source§

type Impl = BrikSelectors

Source§

fn opaque(&self) -> OpaqueElement

Converts self into an opaque representation.
Source§

fn is_html_slot_element(&self) -> bool

Returns whether the element is an HTML element.
Source§

fn parent_node_is_shadow_root(&self) -> bool

Whether the parent node of this element is a shadow root.
Source§

fn containing_shadow_host(&self) -> Option<Self>

The host of the containing shadow root, if any.
Source§

fn parent_element(&self) -> Option<Self>

Source§

fn prev_sibling_element(&self) -> Option<Self>

Skips non-element nodes
Source§

fn next_sibling_element(&self) -> Option<Self>

Skips non-element nodes
Source§

fn first_element_child(&self) -> Option<Self>

Skips non-element nodes
Source§

fn is_empty(&self) -> bool

Returns whether this element matches :empty. Read more
Source§

fn is_root(&self) -> bool

Returns whether this element matches :root, i.e. whether it is the root element of a document. Read more
Source§

fn is_html_element_in_html_document(&self) -> bool

Source§

fn has_local_name(&self, name: &LocalName) -> bool

Source§

fn has_namespace(&self, namespace: &Namespace) -> bool

Empty string for no namespace
Source§

fn is_part(&self, _name: &LocalNameSelector) -> bool

Source§

fn imported_part(&self, _: &LocalNameSelector) -> Option<LocalNameSelector>

Returns the mapping from the exportparts attribute in the reverse direction, that is, in an outer-tree -> inner-tree direction.
Source§

fn is_pseudo_element(&self) -> bool

Whether we’re matching on a pseudo-element.
Source§

fn is_same_type(&self, other: &Self) -> bool

Whether this element and the other element have the same local name and namespace.
Whether this element is a link.
Source§

fn has_id( &self, id: &LocalNameSelector, case_sensitivity: CaseSensitivity, ) -> bool

Source§

fn has_class( &self, name: &LocalNameSelector, case_sensitivity: CaseSensitivity, ) -> bool

Source§

fn attr_matches( &self, ns: &NamespaceConstraint<&Namespace>, local_name: &LocalNameSelector, operation: &AttrSelectorOperation<&AttrValue>, ) -> bool

Source§

fn match_pseudo_element( &self, pseudo: &PseudoElement, _context: &mut MatchingContext<'_, BrikSelectors>, ) -> bool

Source§

fn match_non_ts_pseudo_class( &self, pseudo: &PseudoClass, _context: &mut MatchingContext<'_, BrikSelectors>, ) -> bool

Source§

fn apply_selector_flags(&self, _flags: ElementSelectorFlags)

Sets selector flags on the elemnt itself or the parent, depending on the flags, which indicate what kind of work may need to be performed when DOM state changes.
Source§

fn has_custom_state(&self, _name: &LocalNameSelector) -> bool

Source§

fn add_element_unique_hashes(&self, filter: &mut BloomFilter) -> bool

Add hashes unique to this element to the given filter, returning true if any got added.
Source§

fn pseudo_element_originating_element(&self) -> Option<Self>

The parent of a given pseudo-element, after matching a pseudo-element selector. Read more
Source§

fn has_attr_in_no_namespace( &self, local_name: &<Self::Impl as SelectorImpl>::LocalName, ) -> bool

Source§

fn assigned_slot(&self) -> Option<Self>

Returns the assigned element this element is assigned to. Read more
Source§

fn ignores_nth_child_selectors(&self) -> bool

Returns whether this element should ignore matching nth child selector.
Source§

impl<T> PartialEq for NodeDataRef<T>

Implements PartialEq for NodeDataRef.

Compares NodeDataRef instances by comparing their underlying NodeRef, not the type parameter T. This avoids requiring T: PartialEq.

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq> Eq for NodeDataRef<T>

Auto Trait Implementations§

§

impl<T> Freeze for NodeDataRef<T>

§

impl<T> !RefUnwindSafe for NodeDataRef<T>

§

impl<T> !Send for NodeDataRef<T>

§

impl<T> !Sync for NodeDataRef<T>

§

impl<T> Unpin for NodeDataRef<T>

§

impl<T> !UnwindSafe for NodeDataRef<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.