Skip to main content

FlatNode

Struct FlatNode 

Source
#[non_exhaustive]
pub struct FlatNode {
Show 15 fields pub id: NodeId, pub parent: Option<NodeId>, pub first_child: Option<NodeId>, pub next_sibling: Option<NodeId>, pub span: Range<usize>, pub content_span: Option<Range<usize>>, pub level: Option<u32>, pub kind: String, pub text: Option<String>, pub destination: Option<String>, pub head: Option<bool>, pub alignment: Option<Alignment>, pub name: Option<String>, pub directive_form: Option<DirectiveForm>, pub attrs: Vec<(String, Option<String>)>,
}
Expand description

One node of an Editor::nodes snapshot — the flat AST arena as owned Rust data (the JSON-free read path). id indexes the snapshot; parent, first_child, and next_sibling link the tree (None where absent). text is the node’s primary payload (a str’s bytes, a code_block’s body, …) and destination a link/image target, each None when the kind carries no such payload. #[non_exhaustive]: a snapshot node is something twig hands you, never something you build, so it gains a field whenever a node kind’s payload is surfaced (as head/alignment were for tables). Sealing construction here keeps every future addition a minor release instead of a major one.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: NodeId§parent: Option<NodeId>§first_child: Option<NodeId>§next_sibling: Option<NodeId>§span: Range<usize>§content_span: Option<Range<usize>>§level: Option<u32>

A heading’s level; None for every other kind.

§kind: String§text: Option<String>§destination: Option<String>§head: Option<bool>

Whether a row/cell belongs to the table head; None for every other kind.

§alignment: Option<Alignment>

A cell’s column alignment; None for every other kind. The delimiter row (|:--|--:|) that spells the alignment out is consumed by the parser and has no node of its own, so this is the only way to recover it. Alignment::Default is a real, unspecified alignment (a bare ---) — distinct from the None a non-cell node reports.

§name: Option<String>

The name a kind carries in its own payload rather than in kind: a generic element’s tag ("picture", "source", …) or a directive’s type ("note", "embed", "vis", …, no leading colons). None for every semantic kind, whose identity is kind alone. With this an html_elements parse’s <picture>/<source> are distinguishable — both report kind == "element" — and so are a ::embed and a ::toc, both of which report kind == "directive".

§directive_form: Option<DirectiveForm>

Which of the three surface forms a directive was written in; None for every other kind. Pairs with name: the name says which directive, this says how it was written, and a renderer needs both — the same type is a span inline (DirectiveForm::Text), a standalone block with no body (DirectiveForm::Leaf), and a wrapper around blocks (DirectiveForm::Container).

§attrs: Vec<(String, Option<String>)>

The node’s {...} / HTML attributes as (key, value) pairs in source order (empty when it has none). A bare attribute (HTML disabled, or a <source media=…> used as a flag) has a None value.

Trait Implementations§

Source§

impl Clone for FlatNode

Source§

fn clone(&self) -> FlatNode

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 FlatNode

Source§

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

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

impl Eq for FlatNode

Source§

impl PartialEq for FlatNode

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FlatNode

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.