Skip to main content

Node

Enum Node 

Source
pub enum Node {
Show 30 variants Section(Section), Heading(Heading), Paragraph(Paragraph), List(List), ListItem(ListItem), BlockQuote(BlockQuote), CodeBlock(CodeBlock), Table(Table), TableRow(TableRow), TableCell(TableCell), ThematicBreak(ThematicBreak), Raw(Raw), Text(Text), Emphasis(Emphasis), Strong(Strong), InlineCode(InlineCode), Link(Link), Image(Image), LineBreak(LineBreak), Admonition(Admonition), DefinitionList(DefinitionList), DefinitionTerm(DefinitionTerm), DefinitionDescription(DefinitionDescription), FootnoteReference(FootnoteReference), FootnoteDefinition(FootnoteDefinition), Math(Math), Figure(Figure), Caption(Caption), Anchor(Anchor), Custom(Custom),
}
Expand description

A node in the document tree.

Serialized with a type tag holding the Node::kind name, for core kinds, followed by the variant’s fields.

Variants§

§

Section(Section)

A titled section; by convention its first child is a Heading.

§

Heading(Heading)

A heading.

§

Paragraph(Paragraph)

A paragraph.

§

List(List)

A bulleted or numbered list whose children are list items.

§

ListItem(ListItem)

An item of a List.

§

BlockQuote(BlockQuote)

A block quote.

§

CodeBlock(CodeBlock)

A block of code or preformatted text.

§

Table(Table)

A table whose children are table rows.

§

TableRow(TableRow)

A row of a Table whose children are table cells.

§

TableCell(TableCell)

A cell of a TableRow.

§

ThematicBreak(ThematicBreak)

A horizontal rule.

§

Raw(Raw)

Content passed through verbatim to renderers of a matching format, such as inline HTML in Markdown.

§

Text(Text)

Plain text.

§

Emphasis(Emphasis)

Emphasized (usually italic) text.

§

Strong(Strong)

Strongly emphasized (usually bold) text.

§

InlineCode(InlineCode)

Inline code.

A hyperlink.

§

Image(Image)

An image.

§

LineBreak(LineBreak)

A hard line break.

§

Admonition(Admonition)

A callout such as a note or warning.

§

DefinitionList(DefinitionList)

A list of terms and their descriptions: children alternate between Node::DefinitionTerm and one or more Node::DefinitionDescriptions.

§

DefinitionTerm(DefinitionTerm)

A term in a DefinitionList.

§

DefinitionDescription(DefinitionDescription)

The description of the term before it in a DefinitionList.

§

FootnoteReference(FootnoteReference)

A reference to a footnote, e.g. [^1].

§

FootnoteDefinition(FootnoteDefinition)

The text of a footnote.

§

Math(Math)

A mathematical formula, inline or on its own line.

§

Figure(Figure)

Content (usually an image) with an optional Node::Caption as its last child.

§

Caption(Caption)

The caption of a Figure.

§

Anchor(Anchor)

A link target with no content of its own, e.g. a reStructuredText label in front of a paragraph.

§

Custom(Custom)

A node kind defined by a plugin rather than by lsdocs.

Implementations§

Source§

impl Node

Source

pub fn kind(&self) -> Cow<'static, str>

The name plugins use to select this node, e.g. in transformer capabilities: the type tag for core kinds ("heading"), or "custom:<kind>" for custom nodes.

Source

pub fn span(&self) -> Option<Span>

Where this node came from in the source, if known.

Source

pub fn span_mut(&mut self) -> &mut Option<Span>

Mutable access to where this node came from, e.g. to move spans found in a piece of text to where that piece is in the source.

Source

pub fn children(&self) -> &[Node]

This node’s children; empty for leaf kinds.

Source

pub fn children_mut(&mut self) -> Option<&mut Vec<Node>>

Mutable access to this node’s children, or None for leaf kinds.

Source

pub fn descendants(&self) -> Descendants<'_> ⓘ

Iterates over this node and everything below it, depth first.

Trait Implementations§

Source§

impl Clone for Node

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 Debug for Node

Source§

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

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

impl<'de> Deserialize<'de> for Node

Source§

fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Admonition> for Node

Source§

fn from(n: Admonition) -> Self

Converts to this type from the input type.
Source§

impl From<Anchor> for Node

Source§

fn from(n: Anchor) -> Self

Converts to this type from the input type.
Source§

impl From<BlockQuote> for Node

Source§

fn from(n: BlockQuote) -> Self

Converts to this type from the input type.
Source§

impl From<Caption> for Node

Source§

fn from(n: Caption) -> Self

Converts to this type from the input type.
Source§

impl From<CodeBlock> for Node

Source§

fn from(n: CodeBlock) -> Self

Converts to this type from the input type.
Source§

impl From<Custom> for Node

Source§

fn from(n: Custom) -> Self

Converts to this type from the input type.
Source§

impl From<DefinitionDescription> for Node

Source§

fn from(n: DefinitionDescription) -> Self

Converts to this type from the input type.
Source§

impl From<DefinitionList> for Node

Source§

fn from(n: DefinitionList) -> Self

Converts to this type from the input type.
Source§

impl From<DefinitionTerm> for Node

Source§

fn from(n: DefinitionTerm) -> Self

Converts to this type from the input type.
Source§

impl From<Emphasis> for Node

Source§

fn from(n: Emphasis) -> Self

Converts to this type from the input type.
Source§

impl From<Figure> for Node

Source§

fn from(n: Figure) -> Self

Converts to this type from the input type.
Source§

impl From<FootnoteDefinition> for Node

Source§

fn from(n: FootnoteDefinition) -> Self

Converts to this type from the input type.
Source§

impl From<FootnoteReference> for Node

Source§

fn from(n: FootnoteReference) -> Self

Converts to this type from the input type.
Source§

impl From<Heading> for Node

Source§

fn from(n: Heading) -> Self

Converts to this type from the input type.
Source§

impl From<Image> for Node

Source§

fn from(n: Image) -> Self

Converts to this type from the input type.
Source§

impl From<InlineCode> for Node

Source§

fn from(n: InlineCode) -> Self

Converts to this type from the input type.
Source§

impl From<LineBreak> for Node

Source§

fn from(n: LineBreak) -> Self

Converts to this type from the input type.
Source§

impl From<Link> for Node

Source§

fn from(n: Link) -> Self

Converts to this type from the input type.
Source§

impl From<List> for Node

Source§

fn from(n: List) -> Self

Converts to this type from the input type.
Source§

impl From<ListItem> for Node

Source§

fn from(n: ListItem) -> Self

Converts to this type from the input type.
Source§

impl From<Math> for Node

Source§

fn from(n: Math) -> Self

Converts to this type from the input type.
Source§

impl From<Paragraph> for Node

Source§

fn from(n: Paragraph) -> Self

Converts to this type from the input type.
Source§

impl From<Raw> for Node

Source§

fn from(n: Raw) -> Self

Converts to this type from the input type.
Source§

impl From<Section> for Node

Source§

fn from(n: Section) -> Self

Converts to this type from the input type.
Source§

impl From<Strong> for Node

Source§

fn from(n: Strong) -> Self

Converts to this type from the input type.
Source§

impl From<Table> for Node

Source§

fn from(n: Table) -> Self

Converts to this type from the input type.
Source§

impl From<TableCell> for Node

Source§

fn from(n: TableCell) -> Self

Converts to this type from the input type.
Source§

impl From<TableRow> for Node

Source§

fn from(n: TableRow) -> Self

Converts to this type from the input type.
Source§

impl From<Text> for Node

Source§

fn from(n: Text) -> Self

Converts to this type from the input type.
Source§

impl From<ThematicBreak> for Node

Source§

fn from(n: ThematicBreak) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Node

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 Serialize for Node

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Node

Auto Trait Implementations§

§

impl Forget for Node

§

impl Freeze for Node

§

impl Move for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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.