Skip to main content

NodeRef

Struct NodeRef 

Source
pub struct NodeRef<'a> { /* private fields */ }
Expand description

A node, borrowing from the frame it was parsed from.

Implementations§

Source§

impl<'a> NodeRef<'a>

Source

pub const fn tag(&self) -> Value<'a>

The node’s tag.

Source

pub const fn attr_count(&self) -> usize

How many attributes the node carries.

Source

pub const fn has_content(&self) -> bool

Whether the node has a body.

Source

pub fn attrs(&self) -> Attrs<'a> ⓘ

The attributes, in the order the frame carried them.

Source

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

The first value for key.

Attribute keys are tokens or short strings, so a linear scan over the handful a stanza carries beats building an index.

Source

pub fn attr_eq(&self, key: &str, expected: &str) -> bool

Whether an attribute equals expected — the comparison L1 derivation leans on, done without allocating.

Source

pub fn content(&self) -> Content<'a>

The node’s body.

Source

pub fn children(&self) -> Children<'a> ⓘ

The child nodes, or an empty iterator when the body is not a list.

Source

pub fn child_at(&self, index: usize) -> Option<NodeRef<'a>>

The child at index.

Source

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

The first child whose tag is tag.

Source

pub fn at_path<I>(&self, path: I) -> Option<NodeRef<'a>>
where I: IntoIterator<Item = u16>,

Follow a path of child indices from this node.

This is how an envelope’s plaintext entries find the node they belong to: the path in a PlaintextEntry addresses exactly this walk.

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> Self

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> Copy for NodeRef<'a>

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<'a> Eq for NodeRef<'a>

Source§

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

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.