#[non_exhaustive]pub enum Event {
Show 42 variants
EndBlockQuote,
EndCaption,
EndDefinitionDetail,
EndDefinitionList,
EndDefinitionTerm,
EndDocument,
EndFootnote,
EndHeading,
EndLink,
EndOrderedListItem,
EndParagraph,
EndPreformatted,
EndTable,
EndTableCell,
EndTableHeader,
EndTableRow,
EndTextStyle,
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>,
},
StartTextStyle {
kind: TextStyleKind,
id: Option<String>,
},
StartUnorderedListItem {
id: Option<String>,
level: u32,
style_type: ListStyleType,
},
Text {
content: String,
},
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; downstream consumers must include a wildcard _ => arm when
matching.
Events come in three categories:
- Start/End pairs: Container elements like headings, paragraphs, tables.
Every
Start*has exactly one matchingEnd*(Rule 1 in module docs). - Self-contained: Standalone elements like text, images, line breaks.
- Block vs Inline: Block events create new vertical sections; inline events flow within blocks.
See the module-level documentation for error handling, asset references, and the full well-formedness ruleset.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
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.
EndLink
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.
EndTextStyle
End an inline text style span.
EndUnorderedListItem
End an unordered (bulleted) list item.
FootnoteRef
A reference to a footnote.
Inline marker; the corresponding Event::StartFootnote definition appears
elsewhere in the stream (before or after this reference, depending on source
format). Each footnote ID appears in exactly one FootnoteRef and one
Event::StartFootnote (Rule 7 in module docs).
Image
An image reference.
Asset bytes resolve lazily via crate::AssetProvider. decorative means
purely visual — no alt text is needed for accessibility. Images may appear
inline within paragraphs/headings or directly in block containers.
Fields
source: ImageSourceSource of the image (embedded asset or external URI).
LineBreak
A hard line break within a paragraph.
Explicit hard break (e.g., markdown two-space-newline, HTML <br>).
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.
May contain any block element.
StartCaption
Begin a table caption.
Appears at most once per table, before any rows (Rule 6 in module docs).
StartDefinitionDetail
Begin a definition detail (description).
Details can contain any block element.
StartDefinitionList
Begin a definition list.
Contains Event::StartDefinitionTerm / Event::StartDefinitionDetail
pairs.
StartDefinitionTerm
Begin a definition term.
Terms contain inline content only.
StartDocument
Begin a document with optional language and metadata.
The root container — exactly one per stream (Rule 2 in module docs).
language is a BCP 47 tag (e.g., "en", "en-US", "zh-Hans").
Fields
metadata: Option<DocumentMeta>Document metadata including title, authors, and description.
StartFootnote
Begin a footnote definition.
Readers emit StartFootnote as soon as practical; placement varies by
source format. The corresponding Event::FootnoteRef may appear before
or after this definition. Writers decide final placement and must buffer
if needed. Footnotes contain paragraphs only; this restriction may relax
in future versions.
StartHeading
Begin a heading of the given level.
Levels 1–6 are standard (HTML). DOCX/ODT/RTF support 1–9. Writers clamp
higher levels to their format’s maximum. Heading levels are 1-based (range
1–9); list item level (on Event::StartOrderedListItem and
Event::StartUnorderedListItem) is 0-indexed.
Fields
StartLink
Begin a hyperlink.
An inline container (uses Start/End because it carries href). Valid
inside paragraphs, headings, list items, cells, and definition details.
Links do not nest (Rule 4 in module docs).
Fields
StartOrderedListItem
Begin an ordered (numbered) list item.
See Event::StartUnorderedListItem for nesting and list-boundary
semantics — they apply identically here. start is populated only on
the first item of an ordered list; subsequent items use None.
Fields
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: ListStyleTypeVisual 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.
StartPreformatted
Begin a preformatted (code) block with optional syntax highlighting.
Inside StartPreformatted/Event::EndPreformatted, no
Event::StartTextStyle events appear (Rule 11 in module docs). When
syntax is present, the block has code semantics. Newlines in content
are literal.
Fields
StartTable
Begin a table.
Contains an optional Event::StartCaption (at most one, before any
rows), then Event::StartTableRow events. Cells may contain any block
element.
StartTableCell
Begin a table data cell.
Data cells omit the scope and abbr fields carried by
Event::StartTableHeader; use the header variant for cells that
describe other cells.
Fields
StartTableHeader
Begin a table header cell.
Header cells carry scope and abbr for accessibility; data cells (use
Event::StartTableCell) omit these.
Fields
scope: Option<TableHeaderScope>Whether this header applies to a column or row.
StartTableRow
Begin a table row.
StartTextStyle
Begin an inline text style span.
Valid inside paragraphs, headings, list items, cells, and definition
details. Style spans nest but never overlap (Rules 1 and 9 in module
docs); readers MUST close-and-reopen to express overlapping source
styles. The TextStyleKind::Mark variant carries the highlight color;
TextStyleKind::TextColor carries the foreground text color.
Fields
kind: TextStyleKindThe style kind opened by this span.
StartUnorderedListItem
Begin an unordered (bulleted) list item.
Child items nest inside the parent’s Start*/End* pair; the parent’s
Event::EndUnorderedListItem appears AFTER all children and any
continuation content (paragraphs, line breaks) belonging to the parent.
level is 0-indexed and authoritative — writers may rely on it alone.
List boundaries (applies to Event::StartOrderedListItem as well):
a new list begins when (a) a non-list block intervenes, (b) ordered vs.
unordered changes at the same level, or (c) level decreases then
increases without a parent.
Fields
style_type: ListStyleTypeVisual style of the list marker. Writers tolerate mismatches per ListStyleType convention.
Text
A text run.
Whitespace is significant. Outside preformatted blocks, newlines in
content are collapsed to whitespace; readers emit Event::LineBreak
for explicit hard breaks (e.g., markdown two-space-newline, HTML <br>)
and Event::SoftBreak for soft breaks (e.g., source line wraps
within a paragraph). Inline formatting is expressed via surrounding
Event::StartTextStyle/Event::EndTextStyle wrapper events; the
Text event itself carries content only.
ThematicBreak
A horizontal rule / thematic break.
Section separator. Self-contained block event.