Skip to main content

NodeRef

Struct NodeRef 

Source
pub struct NodeRef<'a> {
    pub tag: NodeStr<'a>,
    pub attrs: AttrsRef<'a>,
    pub content: Option<Box<NodeContentRef<'a>>>,
}

Fields§

§tag: NodeStr<'a>§attrs: AttrsRef<'a>§content: Option<Box<NodeContentRef<'a>>>

Implementations§

Source§

impl<'a> NodeRef<'a>

Source

pub fn new( tag: NodeStr<'a>, attrs: AttrsRef<'a>, content: Option<NodeContentRef<'a>>, ) -> Self

Source

pub fn attrs(&self) -> AttrParserRef<'_>

Source

pub fn children(&self) -> Option<&[NodeRef<'a>]>

Source

pub fn get_attr(&self, key: &str) -> Option<&ValueRef<'a>>

Source

pub fn attrs_iter(&self) -> impl Iterator<Item = (&NodeStr<'a>, &ValueRef<'a>)>

Source

pub fn get_optional_child_by_tag(&self, tags: &[&str]) -> Option<&NodeRef<'a>>

Source

pub fn get_children_by_tag<'b>( &'b self, tag: &'b str, ) -> impl Iterator<Item = &'b NodeRef<'a>>
where 'a: 'b,

Source

pub fn get_optional_child(&self, tag: &str) -> Option<&NodeRef<'a>>

Source

pub fn content_as_string(&self) -> Option<CompactString>

Extract text content, handling both String and Bytes (lossy UTF-8).

Source

pub fn content_bytes(&self) -> Option<&[u8]>

Zero-copy byte content, if this node has Bytes content.

Source

pub fn content_str(&self) -> Option<&str>

Zero-copy string content, if this node has String content.

Source

pub fn content_nodes(&self) -> Option<&[NodeRef<'a>]>

Child nodes from content, if this node has Nodes content. Alias for children().

Source

pub fn to_owned(&self) -> Node

Trait Implementations§

Source§

impl<'a> Clone for NodeRef<'a>

Source§

fn clone(&self) -> NodeRef<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for NodeRef<'a>

Source§

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

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

impl EncodeNode for NodeRef<'_>

Source§

fn tag(&self) -> &str

Source§

fn attrs_len(&self) -> usize

Source§

fn has_content(&self) -> bool

Source§

fn encode_attrs<'a, W: ByteWriter>( &self, encoder: &mut Encoder<'a, W>, ) -> Result<()>

Encode all attributes to the encoder
Source§

fn encode_content<'a, W: ByteWriter>( &self, encoder: &mut Encoder<'a, W>, ) -> Result<()>

Encode content (string, bytes, or child nodes) to the encoder
Source§

impl<'a> PartialEq for NodeRef<'a>

Source§

fn eq(&self, other: &NodeRef<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<'yoke> Yokeable<'yoke> for NodeRef<'static>

Source§

type Output = NodeRef<'yoke>

This type MUST be Self with the 'static replaced with 'a, i.e. Self<'a>
Source§

fn transform(&'yoke self) -> &'yoke Self::Output

This method must cast self between &'a Self<'static> and &'a Self<'a>. Read more
Source§

fn transform_owned(self) -> Self::Output

This method must cast self between Self<'static> and Self<'a>. Read more
Source§

unsafe fn make(from: Self::Output) -> Self

This method can be used to cast away Self<'a>’s lifetime. Read more
Source§

fn transform_mut<F>(&'yoke mut self, f: F)
where F: 'static + for<'_yoke> FnOnce(&'_yoke mut Self::Output),

This method must cast self between &'a mut Self<'static> and &'a mut Self<'a>, and pass it to f. Read more
Source§

impl<'a> StructuralPartialEq for NodeRef<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for NodeRef<'a>

§

impl<'a> RefUnwindSafe for NodeRef<'a>

§

impl<'a> Send for NodeRef<'a>

§

impl<'a> Sync for NodeRef<'a>

§

impl<'a> Unpin for NodeRef<'a>

§

impl<'a> UnsafeUnpin for NodeRef<'a>

§

impl<'a> UnwindSafe for NodeRef<'a>

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<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<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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,