pub enum MessageContent {
Text(String),
Parts(Vec<ContentPart>),
}Expand description
The content of one message: prose, or parts when some of it is not prose.
Variants§
Text(String)
Prose, and nothing else. The wire form is a bare string.
Parts(Vec<ContentPart>)
An ordered list of parts, at least one of which is usually not text.
Implementations§
Source§impl MessageContent
impl MessageContent
Sourcepub fn as_text(&self) -> Option<&str>
pub fn as_text(&self) -> Option<&str>
The content as one string, when it is text and nothing else.
None for a parts list — including a parts list that happens to hold
only text — because a caller reaching for this wants to know it is
seeing the whole message. Use to_text to read what
text there is regardless.
Sourcepub fn to_text(&self) -> String
pub fn to_text(&self) -> String
Every text part, joined with a newline. Parts carrying bytes or a URI contribute nothing — this is the text, not a description of the message.
Sourcepub fn parts(&self) -> impl Iterator<Item = &ContentPart>
pub fn parts(&self) -> impl Iterator<Item = &ContentPart>
The parts, with a text-only content read as a single text part.
Trait Implementations§
Source§impl Clone for MessageContent
impl Clone for MessageContent
Source§impl Debug for MessageContent
Vec<u8> in a Debug line is one number per byte. A megabyte of PDF in a
log is not a diagnostic, so the bytes are reported as a count.
impl Debug for MessageContent
Vec<u8> in a Debug line is one number per byte. A megabyte of PDF in a
log is not a diagnostic, so the bytes are reported as a count.