pub enum RunContent {
Text(String),
Image(Box<Image>),
Field(Field),
NoteReference(NoteReference),
NoteMarker(NoteKind),
Chart(Box<EmbeddedChart>),
Break(BreakKind),
CarriageReturn,
}Expand description
The content of a Run: text, a single inline image, a field (e.g. a page number), a reference
to a footnote/endnote, or a footnote/endnote’s own number marker.
WordprocessingML’s EG_RunInnerContent technically allows a run to mix several kinds of content
(e.g. text followed by a line break followed by more text), but that generality isn’t modeled
yet — a run is either all text, a single image, a single field, a single note reference/marker,
or a single break. Split content across multiple runs (e.g. one text run, then a break run, then
another text run) if that’s needed — this crate always represents a break as a run of its own,
rather than mixing content kinds within a single run. Note that a Field is, strictly, not
really “inside” a run in the underlying XML (<w:fldSimple> is a sibling of <w:r>, wrapping
its own inner run) — it is modeled here as run content anyway, for a simpler, more consistent
public API; see writer.rs’s write_field for how this is reconciled when serializing.
NoteReference/NoteMarker/Break/ CarriageReturn, by contrast, really are plain run
content (EG_RunInnerContent members), no reconciliation needed.
Variants§
Text(String)
Image(Box<Image>)
An inline image. Boxed for the same reason as Chart below — once Chart was boxed,
clippy’s large_enum_variant moved on to flag this as the new largest variant (an Image
carries its own encoded bytes plus shape-formatting fields).
Field(Field)
NoteReference(NoteReference)
NoteMarker(NoteKind)
Chart(Box<EmbeddedChart>)
An embedded chart (<w:drawing><wp:inline> wrapping a <c:chart r:id=".."> graphic frame
instead of a picture). See EmbeddedChart’s doc comment. Boxed for the same reason as
powerpoint-ooxml’s Shape::Chart — a chart’s own nested ChartSpace otherwise forces
every RunContent, whatever its real kind, to pay for the largest variant’s size.
Break(BreakKind)
An explicit page/column/line break (<w:br>, CT_Br). See BreakKind’s doc comment.
CarriageReturn
A simple carriage return / line break (<w:cr/>, CT_Empty) — distinct from
Break(BreakKind::TextWrapping): both produce a line break, but w:cr is
WordprocessingML’s older, simpler element for it (no type/clear attributes at all),
while w:br with type="textWrapping" is the modern, more general one. This crate writes
whichever the caller explicitly asks for; both round-trip back to their own distinct variant
when read.
Trait Implementations§
Source§impl Clone for RunContent
impl Clone for RunContent
Source§fn clone(&self) -> RunContent
fn clone(&self) -> RunContent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more