Skip to main content

RunContent

Enum RunContent 

Source
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

Source§

fn clone(&self) -> RunContent

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 RunContent

Source§

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

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

impl Default for RunContent

Source§

fn default() -> RunContent

Returns the “default value” for a type. Read more
Source§

impl PartialEq for RunContent

Source§

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

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> Same for T

Source§

type Output = T

Should always be Self
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.