#[non_exhaustive]pub enum RunContent {
Text(String),
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
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.
Text(String)
Plain text.
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_control(&self) -> Option<&Control>
pub fn as_control(&self) -> Option<&Control>
Returns the control if this is a Control variant.
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
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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>,
Deserialize this value from the given Serde deserializer. Read more
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>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for RunContent
impl PartialEq for RunContent
Source§impl Serialize for RunContent
impl Serialize for RunContent
impl StructuralPartialEq for RunContent
Auto Trait Implementations§
impl Freeze for RunContent
impl RefUnwindSafe for RunContent
impl Send for RunContent
impl Sync for RunContent
impl Unpin for RunContent
impl UnwindSafe for RunContent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more