#[non_exhaustive]pub enum RunContent {
Text(String),
InlineText(InlineText),
Table(Box<Table>),
Image(Image),
Control(Box<Control>),
}Expand description
The content of a run.
Marked #[non_exhaustive] so future content types can be added
without a breaking change.
§Design Decision
Table and Control are boxed to keep the enum size small.
The common case (Text) is 24 bytes (a String). Without boxing,
the enum would be ~88 bytes (dominated by the Control variant).
§Examples
use hwpforge_core::run::RunContent;
let text = RunContent::Text("Hello".to_string());
assert!(text.is_text());
assert_eq!(text.as_text(), Some("Hello"));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Text(String)
Plain text.
InlineText(InlineText)
Rich inline text that needs per-segment attributes (e.g. an
inline <hp:tab width="..." leader="..." type="..."/>). Used
only when Text(String) cannot represent the payload —
projection still prefers Text for the common plain-string
case to keep the audit baseline and downstream encoders simple.
See crate::inline::InlineText for the design notes.
Table(Box<Table>)
An inline table (boxed for enum size optimization).
Image(Image)
An inline image.
Control(Box<Control>)
A control element (boxed for enum size optimization).
Implementations§
Source§impl RunContent
impl RunContent
Sourcepub fn as_text(&self) -> Option<&str>
pub fn as_text(&self) -> Option<&str>
Returns the text content if this is a Text variant.
§Examples
use hwpforge_core::run::RunContent;
let content = RunContent::Text("hello".to_string());
assert_eq!(content.as_text(), Some("hello"));
let content = RunContent::Text(String::new());
assert_eq!(content.as_text(), Some(""));Sourcepub fn as_inline_text(&self) -> Option<&InlineText>
pub fn as_inline_text(&self) -> Option<&InlineText>
Returns the InlineText if this is an InlineText variant.
Sourcepub fn plain_text(&self) -> Option<Cow<'_, str>>
pub fn plain_text(&self) -> Option<Cow<'_, str>>
Returns the plain-text equivalent of any text-bearing variant
(Text or InlineText). For RunContent::InlineText, each
Tab segment renders as \t. Returns None for Table,
Image, and Control variants.
Use this from callers (Markdown bridge, CLI search, etc.) that need text payload without inspecting per-segment attributes.
Sourcepub fn as_control(&self) -> Option<&Control>
pub fn as_control(&self) -> Option<&Control>
Returns the control if this is a Control variant.
Sourcepub fn is_inline_text(&self) -> bool
pub fn is_inline_text(&self) -> bool
Returns true if this is an InlineText variant.
Sourcepub fn carries_text(&self) -> bool
pub fn carries_text(&self) -> bool
Returns true for any text-bearing variant (Text or InlineText).
Sourcepub fn is_control(&self) -> bool
pub fn is_control(&self) -> bool
Returns true if this is a Control variant.
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 moreSource§impl Debug for RunContent
impl Debug for RunContent
Source§impl<'de> Deserialize<'de> for RunContent
impl<'de> Deserialize<'de> for RunContent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for RunContent
impl Display for RunContent
Source§impl JsonSchema for RunContent
impl JsonSchema for RunContent
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for RunContent
impl PartialEq for RunContent
Source§fn eq(&self, other: &RunContent) -> bool
fn eq(&self, other: &RunContent) -> bool
self and other values to be equal, and is used by ==.