Skip to main content

NodeKind

Enum NodeKind 

Source
#[repr(u32)]
pub enum NodeKind { Element = 1, Attribute = 2, Text = 3, CData = 4, EntityRef = 5, Comment = 8, Pi = 7, Document = 9, DocumentFragment = 11, Dtd = 14, DtdDecl = 15, }
Expand description

Discriminant for Node::kind.

#[repr(u32)] chosen to match libxml2’s xmlElementType numeric layout — the future extern "C" shim can transmute / cast directly. Variant values are pinned to libxml2’s enum order; do not reorder without a coordinated ABI update.

Variants§

§

Element = 1

<element>...</element>.

§

Attribute = 2

An attribute. Only used as the kind of an Attribute under the c-abi feature — never appears on a real Node; the libxml2 ABI requires xmlAttr’s type field at offset 8 to carry this discriminant so generic walkers casting xmlAttr* to xmlNode* see the right type.

§

Text = 3

Character data between tags. content holds the (entity-expanded) text.

§

CData = 4

<![CDATA[…]]>. Preserved as a distinct kind for round-trip serialization.

§

EntityRef = 5

An unresolved entity reference — &name; left literal in the tree. Emitted only when the parser is configured with resolve_entities: false; the default expands entity references inline. name holds the entity name (e.g. "foo" for &foo;); content holds the literal source form "&foo;" so serialization round-trips by writing content verbatim, and lxml-compat code can return node.text == "&foo;".

libxml2’s enum value for XML_ENTITY_REF_NODE is 5 — pinned here so generic walkers see the right tag.

§

Comment = 8

<!-- … -->.

§

Pi = 7

<?target content?>.

§

Document = 9

The document root. Only used as the kind of an XmlDoc under the c-abi feature — never appears on a real Node. libxml2’s enum value for XML_DOCUMENT_NODE is 9.

§

DocumentFragment = 11

A detached subtree root with no semantic content of its own — just a parent for an ordered list of child nodes. Returned by xmlNewDocFragment and used by callers that want to build a composite subtree before grafting it into a real document.

libxml2’s enum value for XML_DOCUMENT_FRAG_NODE is 11.

§

Dtd = 14

The DOCTYPE internal-subset node itself (XML_DTD_NODE = 14). Never allocated in the arena — sup-xml models the DTD through the compat shim’s 128-byte xmlDtd struct, which shares the node header (kind@8, children@24, parent@40, next@48, prev@56, doc@64) with Node. The shim splices that struct into the document’s sibling chain at the DOCTYPE’s true position; reinterpreted as a Node it reports this kind, so every tree walker traverses past it as an inert node (it emits no markup of its own — lxml serializes the subset via doc->intSubset directly).

§

DtdDecl = 15

A document-type internal-subset declaration block (<!ENTITY …>, <!ELEMENT …>, <!ATTLIST …>, …). Held as the single child of the internal-subset DTD node; content carries the raw markup declarations (each terminated by a newline) verbatim, which the serializer emits unescaped inside the DOCTYPE’s [ … ]. The discriminant sits in libxml2’s declaration-type range (XML_ELEMENT_DECL = 15) so generic walkers treat it as a DTD declaration; sup-xml does not model per-declaration nodes.

Trait Implementations§

Source§

impl Clone for NodeKind

Source§

fn clone(&self) -> NodeKind

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 Copy for NodeKind

Source§

impl Debug for NodeKind

Source§

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

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

impl Eq for NodeKind

Source§

impl Hash for NodeKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for NodeKind

Source§

fn eq(&self, other: &NodeKind) -> 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 StructuralPartialEq for NodeKind

Auto Trait Implementations§

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.