Skip to main content

Event

Enum Event 

Source
#[non_exhaustive]
pub enum Event {
Show 40 variants EndBlockQuote, EndCaption, EndDefinitionDetail, EndDefinitionList, EndDefinitionTerm, EndDocument, EndFootnote, EndHeading, EndLink, EndOrderedListItem, EndParagraph, EndPreformatted, EndTable, EndTableCell, EndTableHeader, EndTableRow, EndUnorderedListItem, FootnoteRef { id: u32, }, Image { alt: Option<String>, decorative: bool, id: Option<String>, source: ImageSource, title: Option<String>, }, LineBreak, SoftBreak, StartBlockQuote { id: Option<String>, }, StartCaption { id: Option<String>, }, StartDefinitionDetail { id: Option<String>, }, StartDefinitionList { id: Option<String>, }, StartDefinitionTerm { id: Option<String>, }, StartDocument { id: Option<String>, language: Option<String>, metadata: Option<DocumentMeta>, }, StartFootnote { id: u32, }, StartHeading { id: Option<String>, level: u8, }, StartLink { href: String, id: Option<String>, title: Option<String>, }, StartOrderedListItem { id: Option<String>, level: u32, start: Option<u64>, style_type: ListStyleType, }, StartParagraph { alignment: Option<TextAlignment>, id: Option<String>, }, StartPreformatted { id: Option<String>, syntax: Option<String>, }, StartTable { id: Option<String>, }, StartTableCell { colspan: Option<u32>, id: Option<String>, rowspan: Option<u32>, }, StartTableHeader { abbr: Option<String>, colspan: Option<u32>, id: Option<String>, rowspan: Option<u32>, scope: Option<TableHeaderScope>, }, StartTableRow { id: Option<String>, }, StartUnorderedListItem { id: Option<String>, level: u32, style_type: ListStyleType, }, Text { content: String, style: TextStyle, }, ThematicBreak { id: Option<String>, },
}
Expand description

A streaming document event.

Events flow from crate::EventSource readers to crate::EventSink writers. The enum is marked #[non_exhaustive] to allow adding new event types in future versions.

Events come in three categories:

  • Start/End pairs: Container elements like headings, paragraphs, tables
  • Self-contained: Standalone elements like text, images, line breaks
  • Block vs Inline: Block events create new vertical sections; inline events flow within blocks

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

EndBlockQuote

End a block quote.

§

EndCaption

End a table caption.

§

EndDefinitionDetail

End a definition detail.

§

EndDefinitionList

End a definition list.

§

EndDefinitionTerm

End a definition term.

§

EndDocument

End a document.

§

EndFootnote

End a footnote definition.

§

EndHeading

End a heading.

End a hyperlink.

§

EndOrderedListItem

End an ordered (numbered) list item.

§

EndParagraph

End a paragraph.

§

EndPreformatted

End a preformatted block.

§

EndTable

End a table.

§

EndTableCell

End a table data cell.

§

EndTableHeader

End a table header cell.

§

EndTableRow

End a table row.

§

EndUnorderedListItem

End an unordered (bulleted) list item.

§

FootnoteRef

A reference to a footnote.

Fields

§id: u32

The footnote identifier being referenced.

§

Image

An image reference.

Fields

§alt: Option<String>

Alternative text for accessibility.

§decorative: bool

Whether the image is purely decorative (no alt text needed).

§id: Option<String>

Optional block identifier for the image.

§source: ImageSource

Source of the image (embedded asset or external URI).

§title: Option<String>

Optional tooltip text.

§

LineBreak

A hard line break within a paragraph.

§

SoftBreak

A soft line break in source markup, such as a markdown line wrap.

Soft breaks correspond to source line wraps that do not enforce a visible break. Writers choose rendering policy: space, newline, <br>, etc.

§

StartBlockQuote

Begin a block quote.

Fields

§id: Option<String>

Optional block identifier.

§

StartCaption

Begin a table caption.

Fields

§id: Option<String>

Optional block identifier.

§

StartDefinitionDetail

Begin a definition detail (description).

Fields

§id: Option<String>

Optional block identifier.

§

StartDefinitionList

Begin a definition list.

Fields

§id: Option<String>

Optional block identifier.

§

StartDefinitionTerm

Begin a definition term.

Fields

§id: Option<String>

Optional block identifier.

§

StartDocument

Begin a document with optional language and metadata.

Fields

§id: Option<String>

Optional block identifier.

§language: Option<String>

BCP 47 language tag (e.g., “en”, “en-US”, “zh-Hans”).

§metadata: Option<DocumentMeta>

Document metadata including title, authors, and description.

§

StartFootnote

Begin a footnote definition.

Fields

§id: u32

Unique identifier for this footnote.

§

StartHeading

Begin a heading of the given level.

Fields

§id: Option<String>

Optional block identifier for the heading.

§level: u8

Heading level, 1–9 (1 is most prominent).

Begin a hyperlink.

Fields

§href: String

URL or URI target of the link.

§id: Option<String>

Optional block identifier.

§title: Option<String>

Optional tooltip text.

§

StartOrderedListItem

Begin an ordered (numbered) list item.

Fields

§id: Option<String>

Optional block identifier.

§level: u32

Zero-indexed nesting depth (0 = top-level list).

§start: Option<u64>

Starting number for the list, populated only on the first item of an ordered list (subsequent items in the same list: None).

§style_type: ListStyleType

Visual style of the list marker. Writers tolerate mismatches per ListStyleType convention.

§

StartParagraph

Begin a paragraph with optional alignment.

Fields

§alignment: Option<TextAlignment>

Text alignment for the paragraph.

§id: Option<String>

Optional block identifier for the paragraph.

§

StartPreformatted

Begin a preformatted (code) block with optional syntax highlighting.

Fields

§id: Option<String>

Optional block identifier.

§syntax: Option<String>

Language identifier for syntax highlighting (e.g., “rust”, “python”).

§

StartTable

Begin a table.

Fields

§id: Option<String>

Optional block identifier.

§

StartTableCell

Begin a table data cell.

Fields

§colspan: Option<u32>

Number of columns this cell spans.

§id: Option<String>

Optional block identifier.

§rowspan: Option<u32>

Number of rows this cell spans.

§

StartTableHeader

Begin a table header cell.

Fields

§abbr: Option<String>

Abbreviated content for accessibility.

§colspan: Option<u32>

Number of columns this cell spans.

§id: Option<String>

Optional block identifier.

§rowspan: Option<u32>

Number of rows this cell spans.

§scope: Option<TableHeaderScope>

Whether this header applies to a column or row.

§

StartTableRow

Begin a table row.

Fields

§id: Option<String>

Optional block identifier.

§

StartUnorderedListItem

Begin an unordered (bulleted) list item.

Fields

§id: Option<String>

Optional block identifier.

§level: u32

Zero-indexed nesting depth (0 = top-level list).

§style_type: ListStyleType

Visual style of the list marker. Writers tolerate mismatches per ListStyleType convention.

§

Text

A text run with formatting attributes.

Fields

§content: String

The text content.

§style: TextStyle

Text formatting attributes.

§

ThematicBreak

A horizontal rule / thematic break.

Fields

§id: Option<String>

Optional block identifier.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

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 Event

Source§

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

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

impl PartialEq for Event

Source§

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

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

§

impl UnwindSafe for Event

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.